simplesquid/nova-enum-field
Nova Enum Field adds a dedicated Laravel Nova field for PHP enums, letting you display and edit enum-backed model attributes as friendly selects or badges. Configure labels, colors, options, and validation for cleaner enum handling in Nova resources.
Install with Composer; there is nothing to publish or configure:
composer require simplesquid/nova-enum-field
Requirements to confirm before you start, as of v3.3.0 (March 2025): PHP 8.2+, Laravel 11.x or 12.x, and Nova 4.x or 5.x. That release dropped PHP 8.1 and Laravel 10.x and added Nova 5 / Laravel 12 support — so if you are still on Laravel 10 or PHP 8.1, pin ^3.2 and stay there until you upgrade. Older Nova majors (3.x and below) need an older tag still; the 3.3 line targets the current Nova field API.
Define your enum as a backed enum so it can be persisted:
enum Status: string
{
case Draft = 'draft';
case Published = 'published';
}
Then swap your hand-maintained Select for the package field:
use SimpleSquid\Nova\Fields\Enum\Enum;
public function fields(Request $request): array
{
return [
Enum::make('Status')->attach(Status::class),
];
}
That single line gives you the form select, the index/detail display, and hydration from the model attribute. The first real use case is exactly this: replacing Select::make('status')->options([...]) that drifts out of sync with the enum every time someone adds a case.
Where to look first: the README for the canonical make/attach signatures (the v3.3 README is the only place the new Nova 5 constraint is spelled out), then src/Enum.php and the filter class — the package is small enough to read end-to-end in ten minutes, which is the fastest way to answer "does it support my label convention?".
One field, three contexts. The same Enum::make(...) call works on forms, detail, and index. Keep it in a shared method (or a trait) if the resource is large, so the enum class is referenced in exactly one place.
Filters alongside the field. Register the enum filter in your resource's filters() method so index filtering uses the same source of truth:
use SimpleSquid\Nova\Fields\Enum\EnumFilter;
public function filters(Request $request): array
{
return [
EnumFilter::make('Status')->attach(Status::class),
];
}
Pair it with validation. The field renders options but does not add request rules. Add Rule::enum yourself:
'status' => ['required', Rule::enum(Status::class)],
If you cast the attribute ('status' => Status::class), the field still reads/writes the scalar backed value — the cast and the field don't conflict, they just operate at different layers.
Legacy enum libraries. If your codebase predates PHP 8.1 enums (BenSampo/laravel-enum or similar), the package is designed to accept those classes through the same attach() call, so you can standardise Nova resources on the package before migrating your enum implementation.
Actions and lenses. Because the field resolves options from the enum class, you can reuse the same attach() in action fields and lens fields without rewriting option arrays — the main payoff of the package over a plain select.
Customising the filter. For "any of these statuses" behaviour or a query that isn't a straight where, subclass the filter and override its query/options rather than writing a bespoke filter from scratch.
Upgrading to the 3.3 line. In practice the bump is a platform bump, not an API change: the make/attach surface is unchanged. Sequence it as Laravel → Nova → this package, run your resource tests against Nova 5's field rendering, and expect the only real work to be the PHP 8.2 minimum (readonly classes, null/false standalone types are available; deprecations from 8.1 dynamic properties start surfacing here).
attach() takes the class string, not an instance. Status::class, not new Status. Passing the wrong thing produces an empty select with no obvious error.draft) instead of human labels, the package doesn't recognise your label convention. Add the expected description/label method to the enum, or override the option list on the field — check the README for which hook your version expects.->nullable() on the field and make the column nullable; otherwise Nova will reject the empty option on submit while the select happily offers it.^3.2 if you are on Laravel 10, ^3.3 once you've upgraded — because composer update on a Laravel 10 app will otherwise resolve down silently or fail on platform requirements in CI. This is still a small, low-star package (single maintainer, no dependents); a Nova major can change the field API, so be prepared to fork — the surface area is one field and one or two filter classes.Status::cases() for the source list, the attach() argument for the class, and dumps()/dd() on the field's resolved options if the select is empty.Select options or convert them to backed enums first.How can I help you explore Laravel packages today?