---
title: "Backed and pure enums — Enums for Laravel | Roundly"
description: "What each helper returns on string-backed, int-backed and pure enums — and where pure enums fall back to the case name."
url: https://roundly-consulting.com/open-source/docs/enums-for-laravel/enum-types
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)

# Backed and pure enums

Helpers is designed for backed enums, and every method also works on pure (non-backed) enums: wherever a backed value would be read — values(), storable(), hasValue(), validationRule(), toOptions(), options(), presentation(), readable() and the #\[TranslatedLabels\] key — the case name is used instead.

```php
use RoundlyConsulting\Enums\Helpers;

enum Status
{
    use Helpers;

    case Active;
    case Archived;
}

Status::Active->readable();         // "Active"
Status::labels()->all();            // ['Active', 'Archived']
Status::values()->all();            // ['Active', 'Archived'] — the names stand in for values
Status::toOptions();                // ['Active' => 'Active', 'Archived' => 'Archived']
Status::options()->first()->value;  // 'Active'
Status::validationRule();           // 'in:Active,Archived'
Status::hasValue('Active');         // true
Status::fromLabel('Archived');      // Status::Archived
Status::count();                    // 2
```

## Behaviour by enum type

| Helper | Backed enum | Pure enum |
| --- | --- | --- |
| `readable(), label(), labels()` | Str::headline() of the backed value (an int as-is) | Str::headline() of the case name |
| `toOptions(), toArray()` | Keyed by backed value | Keyed by case name |
| `options()` | value = backed value | value = case name |
| `names(), collect(), count(), random()` | Same | Same |
| `fromName(), tryFromName(), hasName()` | Same | Same |
| `fromLabel(), tryFromLabel()` | Match readable() | Match readable() |
| `is(), isNot(), isIn(), isNotIn(), whenIs*()` | Same | Same |
| `values(), storable()` | Backed values | Case names |
| `presentation(), presentations()` | value = backed value, native type | value = case name |
| `#[TranslatedLabels] key` | `<group>.<value>` | `<group>.<CaseName>` |
| `validationRule()` | in: rule from the backed values | in: rule from the case names |
| `hasValue()` | Strict match on a backed value | Strict match on a case name |

So on a pure enum, values() and storable() return the case names, validationRule() accepts exactly those names, and hasValue() matches a name strictly.

## Int-backed enums

```php
use RoundlyConsulting\Enums\Helpers;

enum Priority: int
{
    use Helpers;

    case Low = 0;
    case Medium = 5;
    case High = 10;
}

Priority::values();            // [0, 5, 10]
Priority::validationRule();    // 'in:0,5,10'
Priority::hasValue(5);         // true
Priority::hasValue('5');       // false — strict comparison
Priority::Medium->readable();  // "5"
Priority::toOptions();         // [0 => '0', 5 => '5', 10 => '10']
```

hasValue() compares strictly, so pass an int to an int-backed enum — form input arrives as a string. validationRule() works either way, because Laravel’s in rule compares as strings. An int value is its own label (5 → “5”, 0 → “0”, -1 → “-1”) — give int-backed enums real labels with #\[TranslatedLabels\] (the key is enums.priority.5) or by overriding readable(), as shown in Labels from translation files and Translating labels.

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