---
title: "Names, values and labels — Enums for Laravel | Roundly"
description: "names(), values(), storable(), labels(), collect() and count() — every case as a Collection, in declaration order."
url: https://roundly-consulting.com/open-source/docs/enums-for-laravel/names-values-labels
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)

# Names, values and labels

Get every case’s name, backed value or readable label as an Illuminate\\Support\\Collection, in declaration order — call ->all() for a plain array:

```php
NewsCategory::names()->all();    // ['HotNews', 'RegularNews', 'PrivateNews']
NewsCategory::values()->all();   // ['hot-news', 'regular-news', 'private-news']
NewsCategory::storable()->all(); // ['hot-news', 'regular-news', 'private-news']
NewsCategory::labels()->all();   // ['Hot News', 'Regular News', 'Private News']

NewsCategory::collect();  // Collection<NewsCategory> — every case as an instance
NewsCategory::count();    // 3
```

| Method | Returns | Contents |
| --- | --- | --- |
| `names()` | `Collection<int, string>` | Case names. |
| `values()` | `Collection<int, string\|int>` | Backed values (case names on a pure enum). |
| `storable()` | `Collection<int, string\|int>` | Same as values(). |
| `labels()` | `Collection<int, string>` | readable() of every case. |
| `collect()` | `Collection<int, self>` | Every case as an enum instance. |
| `count()` | `int` | The number of cases. |

## Persisting the allowed set

storable() is the persistence-flavoured alias of values() — both return the raw backed values (the case names on a pure enum), handy for validation rules, database enum columns or persisting an allowed set:

```php
use App\Enums\NewsCategory;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Schema::create('articles', function (Blueprint $table): void {
    $table->id();
    $table->string('title');
    $table->enum('category', NewsCategory::storable()->all());
    $table->timestamps();
});
```

## Chaining

Everything returns a regular Illuminate\\Support\\Collection, so the full Collection API is available:

```php
NewsCategory::values()->all();          // plain PHP array
NewsCategory::labels()->implode(', ');  // "Hot News, Regular News, Private News"

NewsCategory::collect()
    ->reject(fn (NewsCategory $category): bool => $category->is(NewsCategory::PrivateNews))
    ->map(fn (NewsCategory $category): string => $category->label())
    ->values()
    ->all();                            // ['Hot News', 'Regular News']
```

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