---
title: "Select options — Enums for Laravel | Roundly"
description: "toOptions() and toArray() build a value => label map for Blade selects, form components, JSON and API responses."
url: https://roundly-consulting.com/open-source/docs/enums-for-laravel/select-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)

# Select options

toOptions() returns a value => label Collection, ready for a <select> element or a form component; toArray() is the same map as a plain array for JSON and API responses:

```php
NewsCategory::toOptions();
// Collection: ['hot-news' => 'Hot News', 'regular-news' => 'Regular News', 'private-news' => 'Private News']

NewsCategory::toArray();
// ['hot-news' => 'Hot News', 'regular-news' => 'Regular News', 'private-news' => 'Private News']
```

## Not in config files

Labels are translated, so build options at runtime — in controllers, views and resources — not inside a config/\*.php file: config loads before the translator exists, and a cached config would freeze the labels in one locale. A config file can hold the translation-free values() instead:

```php
use App\Enums\NewsCategory;

// config/news.php — translation-free, safe to cache
return [
    'categories' => NewsCategory::values()->all(),
];
```

## In a Blade form

Pass the options to the view and render them — the keys are exactly the backed values your validation rule accepts:

```php
use App\Enums\NewsCategory;
use Illuminate\Contracts\View\View;

final class CreateArticleController
{
    public function __invoke(): View
    {
        return view('articles.create', [
            'categories' => NewsCategory::toOptions(),
        ]);
    }
}
```

```blade
<select name="category">
    @foreach ($categories as $value => $label)
        <option value="{{ $value }}" @selected(old('category') === $value)>{{ $label }}</option>
    @endforeach
</select>
```

Labels follow the active locale, so a translated app renders translated options with no extra code. On a pure enum the map is keyed by case name; on an int-backed enum the keys are ints.

## 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)
