New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

datomatic/nova-enum-field

A Laravel Nova PHP 8.1 enum field with filters
180,341 19
Install
composer require datomatic/nova-enum-field
Latest Version:v1.11.1
PHP:>=8.1
Laravel:9 – 13
License:MIT
Last Updated:Oct 6, 2026
Links: GitHub  ·  Packagist
Maintainer: trippo

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

Laravel Nova Enum Field

Nova field for enums in PHP 8.1 and above (both pure Enum and BackedEnum) with datomatic/enum-helper and datomatic/laravel-enum-helper compatibility.

Select field on form

There is also a Nova Select filter and Nova Boolean filter: Select filter Boolean filter

Installation

You can install this package in a Laravel app that uses Nova via composer:

composer require datomatic/nova-enum-field

Setup

use App\Enums\UserType;
use Illuminate\Database\Eloquent\Model;

class Example extends Model
{
    protected $casts = [
        'user_type' => UserType::class,
    ];
}

Usage

You can use the Enum field in your Nova resource like this:

namespace App\Nova;

use App\Enums\UserType;
use Datomatic\Nova\Fields\Enum\Enum;

class Example extends Resource
{
    // ...

    public function fields(Request $request)
    {
        return [
            // ...

            Enum::make('User Type','user_type')->attach(UserType::class),

            // ...
        ];
    }
}

Be aware that order in which methods on the field are called can be sigificant. For example nullable() must be called before before attach(), and options() must be called after attach().

If you use datomatic/laravel-enum-helper you can set optionally a custom dynamic property or/and a subset of cases.
The default property is description.

Enum::make('User Type','user_type')
    ->nullable()
    ->property('excerpt')
    ->cases([UserType::ADMINISTRATOR,UserType::MODERATOR])
    ->attach(UserType::class),

Filters

If you would like to use the provided Nova Select filter, you can include it like this:

namespace App\Nova;

use App\Enums\UserPermissions;
use App\Enums\UserType;
use Datomatic\Nova\Fields\Enum\EnumFilter;

class Example extends Resource
{
    // ...

    public function filters(Request $request)
    {
        return [
            EnumFilter::make('user_type', UserType::class),
                
             // With optional name and default value:
            EnumFilter::make('user_type', UserType::class)
                ->name(__('User Type'))
                ->default(UserType::ADMINISTRATOR)
        ];
    }
}

Alternatively, you may wish to use the provided Nova Boolean filter:

namespace App\Nova;

use App\Enums\UserPermissions;
use App\Enums\UserType;
use Datomatic\Nova\Fields\Enum\EnumBooleanFilter;

class Example extends Resource
{
    // ...

    public function filters(Request $request)
    {
        return [
            EnumBooleanFilter::make('user_type', UserType::class),
                
            // With optional name and default value:
            EnumBooleanFilter::make('user_type', UserType::class)
                ->name(__('User Type'))
                ->default([UserType::ADMINISTRATOR, UserType::MODERATOR])
        ];
    }
}

If you use datomatic/laravel-enum-helper you can set optionally a custom dynamic property or/and a subset of cases.
The default property is description.

// Enum filter
EnumFilter::make('user_type', UserType::class)
    ->name('User Type')
    ->property('excerpt')
    ->cases([UserType::ADMINISTRATOR,UserType::MODERATOR])
// Boolean Enum filter
EnumBooleanFilter::make('user_type', UserType::class)
    ->name('User Type')
    ->property('excerpt')
    ->cases([UserType::ADMINISTRATOR,UserType::MODERATOR])

Credits

Thanks

License

The MIT License (MIT). Please see License File for more information.

Related Packages

simplesquid/nova-enum-field

A Laravel Nova field to add enums to resources.

458,319 52
epartment/nova-dependency-container

A Laravel Nova field container allowing to depend on other fields values

4,703,233 378
eminiarts/nova-tabs

Laravel Nova - Tabs.

4,610,439 464
ebess/advanced-nova-media-library

Laravel Nova tools for managing the Spatie media library.

3,888,853 616
spatie/nova-tags-field

A tags field for Nova apps

2,356,168 301

Version History

Version Released PHP Laravel License
v1.11.1 >=8.1 ^9.0|^10.0|^11.0|^12.0|^13.0 MIT
v1.11.0 >=8.1 ^9.0|^10.0|^11.0|^12.0|^13.0 MIT
v1.10.0 >=8.1 ^9.0|^10.0|^11.0|^12.0 MIT
v1.9.0 >=8.1 ^9.0|^10.0|^11.0 MIT
v1.8.0 >=8.1 ^9.0|^10.0 MIT