---
title: "Front-end options — Enums for Laravel | Roundly"
description: "options() returns typed EnumOption DTOs — value, label and name — the shape JavaScript, Inertia, Vue and React selects expect."
url: https://roundly-consulting.com/open-source/docs/enums-for-laravel/frontend-options
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Enums for Laravel](https://roundly-consulting.com/open-source/docs/enums-for-laravel.md)

# Front-end options

options() returns a Collection of typed EnumOption DTOs — the list-of-objects shape JS selects expect, with the case name included:

```php
NewsCategory::options();
// Collection<EnumOption{ value: 'hot-news', label: 'Hot News', name: 'HotNews' }, ...>

$option = NewsCategory::options()->first();

$option->value; // 'hot-news'
$option->label; // 'Hot News'
$option->name;  // 'HotNews'

$option->toArray();
// ['value' => 'hot-news', 'label' => 'Hot News', 'name' => 'HotNews']
```

## The EnumOption DTO

| Member | Type | Value |
| --- | --- | --- |
| `value` | `string\|int` | The backed value — the case name on a pure enum. |
| `label` | `string` | readable() — translated. |
| `name` | `string` | The case name. |
| `toArray()` | `array` | `['value' => ..., 'label' => ..., 'name' => ...]` |

RoundlyConsulting\\Enums\\DataTransferObjects\\EnumOption is a final readonly class, so an option can’t be changed once it’s built.

## Returning options from a controller

```php
use App\Enums\NewsCategory;
use Illuminate\Http\JsonResponse;
use RoundlyConsulting\Enums\DataTransferObjects\EnumOption;

final class ArticleCategoryController
{
    public function __invoke(): JsonResponse
    {
        return response()->json([
            'categories' => NewsCategory::options()
                ->map(fn (EnumOption $option): array => $option->toArray())
                ->all(),
        ]);
    }
}

// {"categories":[{"value":"hot-news","label":"Hot News","name":"HotNews"}, ...]}
```

The DTO’s properties are public, so the collection also JSON-encodes to the same shape as-is — pass NewsCategory::options() straight to a JSON response or an Inertia prop.

options() keeps this shape for selects. When a status badge needs a colour per case, use presentations() instead — see Badge colours and presentation.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/enums-for-laravel.md)
