---
title: "Enums for Laravel — docs | Roundly"
description: "Developer docs for Enums for Laravel: translated labels, select options, badge colours, case lookups, validation rules and comparisons for PHP enums."
url: https://roundly-consulting.com/open-source/docs/enums-for-laravel
language: en
---

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

Open source

# Enums for Laravel

Install

`composer require roundly-consulting/enums-for-laravel`

Requires: PHP ^8.4 · Laravel ^12.0|^13.0

[GitHub](https://github.com/roundly-consulting/enums-for-laravel) [Packagist](https://packagist.org/packages/roundly-consulting/enums-for-laravel) [Donate (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Patreon](https://www.patreon.com/cw/roundly)

## Overview

A single trait that gives your PHP enums the helpers every Laravel app ends up rewriting: readable, translatable labels — derived from the value or read from your own translation files; names, values and labels as collections; select-ready options and badge-ready presentations with a colour per case; lookups by name or label; a validation rule that never drifts; random picks; expressive comparisons and fluent conditional callbacks. Add RoundlyConsulting\\Enums\\Helpers to a backed or pure enum and you’re done — no service provider, config, migrations or commands. Native to Laravel — built on its own Collection, Str and translator — MIT-licensed, with no dependency beyond Laravel itself.

### What you get

#### Readable, translatable labels

readable() and label() headline the backed value — hot-news becomes “Hot News” — or, with #\[TranslatedLabels\], read every label from your lang/<locale>/enums.php.

#### Names, values and labels

One call each for every case’s name, backed value or label, as Laravel Collections in declaration order.

#### Select-ready options

A value => label map for Blade selects, or typed EnumOption DTOs (value, label, name) for Inertia, Vue and React.

#### Colours for badges and chips

Implement HasColor and presentations() returns the value, translated label and colour of every case — ready for a status badge in any front end.

#### Case lookups

Resolve a case by name or label — strict from\* variants throw, tryFrom\* return null — plus hasName() and hasValue().

#### Validation that never drifts

validationRule() builds the in: rule from the current cases, so adding a case never breaks a form.

#### Comparisons and callbacks

is(), isNot(), isIn(), isNotIn() and fluent whenIs\* callbacks with an optional default branch.

#### One trait, zero setup

No service provider, config, migrations, commands or facade. Works on backed and pure enums — pure enums use the case name wherever a value is read.

### Documentation

#### [Installation](https://roundly-consulting.com/open-source/docs/enums-for-laravel/installation.md)

Install with Composer — there is no service provider, config, migration or command to publish or register.

#### [Quick start](https://roundly-consulting.com/open-source/docs/enums-for-laravel/quick-start.md)

Add the Helpers trait to an enum and get labels, options, lookups, validation and comparisons in one line.

#### [Backed and pure enums](https://roundly-consulting.com/open-source/docs/enums-for-laravel/enum-types.md)

What each helper returns on string-backed, int-backed and pure enums — and where pure enums fall back to the case name.

#### [Readable labels](https://roundly-consulting.com/open-source/docs/enums-for-laravel/labels.md)

readable() and label() turn a case into a human-friendly label with Str::headline(), passed through Laravel’s translator.

#### [Translating labels](https://roundly-consulting.com/open-source/docs/enums-for-laravel/translating-labels.md)

Localize labels with JSON translation files or a #\[TranslatedLabels\] group, or override readable() on the enum for full control.

#### [Labels from translation files](https://roundly-consulting.com/open-source/docs/enums-for-laravel/label-groups.md)

#\[TranslatedLabels\] reads every label from a translation group such as lang/<locale>/enums.php, keeps the headline as fallback and lists missing lines.

#### [Names, values and labels](https://roundly-consulting.com/open-source/docs/enums-for-laravel/names-values-labels.md)

names(), values(), storable(), labels(), collect() and count() — every case as a Collection, in declaration order.

#### [Select options](https://roundly-consulting.com/open-source/docs/enums-for-laravel/select-options.md)

toOptions() and toArray() build a value => label map for Blade selects, form components, JSON and API responses.

#### [Front-end options](https://roundly-consulting.com/open-source/docs/enums-for-laravel/frontend-options.md)

options() returns typed EnumOption DTOs — value, label and name — the shape JavaScript, Inertia, Vue and React selects expect.

#### [Badge colours and presentation](https://roundly-consulting.com/open-source/docs/enums-for-laravel/presentation.md)

Give each case a colour with HasColor; presentation() and presentations() return {value, label, color} DTOs for badges and status chips.

#### [Case lookups](https://roundly-consulting.com/open-source/docs/enums-for-laravel/lookups.md)

Resolve a case by name or readable label with fromName(), fromLabel() and their tryFrom\* variants; check existence with hasName() and hasValue().

#### [Validation](https://roundly-consulting.com/open-source/docs/enums-for-laravel/validation.md)

validationRule() builds a Laravel in: rule from values(), so the allow-list never drifts when cases change.

#### [Equality checks](https://roundly-consulting.com/open-source/docs/enums-for-laravel/comparisons.md)

is(), isNot(), isIn() and isNotIn() compare cases by identity — readable conditions without manual === chains.

#### [Conditional callbacks](https://roundly-consulting.com/open-source/docs/enums-for-laravel/conditional-callbacks.md)

whenIs(), whenIsNot(), whenIsIn() and whenIsNotIn() run a callback only when the condition matches, with an optional default.

#### [Random cases & factories](https://roundly-consulting.com/open-source/docs/enums-for-laravel/random-cases.md)

random() picks a random case for model factories, seeders and demo data; collect() walks every case.

#### [Exceptions](https://roundly-consulting.com/open-source/docs/enums-for-laravel/exceptions.md)

EnumException — thrown by lookups, random(), validationRule(), untranslated() and invalid label groups — extends InvalidArgumentException.

#### [API reference](https://roundly-consulting.com/open-source/docs/enums-for-laravel/api-reference.md)

Every static and instance method the Helpers trait adds — signature, return type and purpose — plus the attribute, contract and DTOs.

#### [Testing](https://roundly-consulting.com/open-source/docs/enums-for-laravel/testing.md)

Assert labels, options and validation in Pest, pin translations with untranslated(), add lines with Lang::addLines(), and run the package suite.

#### [Requirements](https://roundly-consulting.com/open-source/docs/enums-for-laravel/requirements.md)

PHP 8.4+ and Laravel 12 or 13 — no PHP extensions, no service provider, no config.

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