PHPackages                             simplesquid/nova-enum-field - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. simplesquid/nova-enum-field

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

simplesquid/nova-enum-field
===========================

A Laravel Nova field to add enums to resources.

v3.3.0(1y ago)52391.9k↑16.1%29[1 PRs](https://github.com/simplesquid/nova-enum-field/pulls)2MITPHPPHP ^8.2CI passing

Since Sep 7Pushed 1y ago3 watchersCompare

[ Source](https://github.com/simplesquid/nova-enum-field)[ Packagist](https://packagist.org/packages/simplesquid/nova-enum-field)[ Docs](https://github.com/simplesquid/nova-enum-field)[ RSS](/packages/simplesquid-nova-enum-field/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (21)Used By (2)

An enum field for Laravel Nova
==============================

[](#an-enum-field-for-laravel-nova)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3d984147caf05389a081845c4a0875df379de8090bce0419bd2a4d2c155e46a3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696d706c6573717569642f6e6f76612d656e756d2d6669656c642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/simplesquid/nova-enum-field)[![Tests](https://github.com/simplesquid/nova-enum-field/actions/workflows/run-tests.yml/badge.svg)](https://github.com/simplesquid/nova-enum-field/actions/workflows/run-tests.yml)[![Code styling](https://github.com/simplesquid/nova-enum-field/actions/workflows/code-style.yml/badge.svg)](https://github.com/simplesquid/nova-enum-field/actions/workflows/code-style.yml)[![MIT License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/abcab39af759ce2f82d093b98282015fdcdf997dff0cef2ee41b16137df57d27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73696d706c6573717569642f6e6f76612d656e756d2d6669656c642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/simplesquid/nova-enum-field)

Laravel Nova field to add enums to resources. This field uses the [BenSampo/laravel-enum](https://github.com/BenSampo/laravel-enum) package, so make sure to check out the installation instructions there first.

[![Screenshot of the enum field](https://github.com/simplesquid/nova-enum-field/raw/main/docs/screenshot.png)](https://github.com/simplesquid/nova-enum-field/raw/main/docs/screenshot.png)

Installation
------------

[](#installation)

You can install this package in a Laravel app that uses [Nova](https://nova.laravel.com) via composer:

```
composer require simplesquid/nova-enum-field
```

Setup
-----

[](#setup)

It is strongly recommended that you use Attribute Casting in your models. From the docs at [BenSampo/laravel-enum](https://github.com/BenSampo/laravel-enum#attribute-casting), this can be done like this:

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

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

Usage
-----

[](#usage)

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

```
namespace App\Nova;

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

class Example extends Resource
{
    // ...

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

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

            // ...
        ];
    }
}
```

### Flagged Enums

[](#flagged-enums)

You can use the `FlaggedEnum` field in your Nova resource like this (see [Flagged/Bitwise Enum](https://github.com/BenSampo/laravel-enum#flaggedbitwise-enum) setup):

```
namespace App\Nova;

use App\Enums\UserPermissions;
use SimpleSquid\Nova\Fields\Enum\FlaggedEnum;

class Example extends Resource
{
    // ...

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

            FlaggedEnum::make('User Permissions')->attach(UserPermissions::class),

            // ...
        ];
    }
}
```

### Filters

[](#filters)

If you would like to use the provided Nova Select filter (which is compatible with both the `Enum` and `FlaggedEnum` fields), you can include it like this:

```
namespace App\Nova;

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

class Example extends Resource
{
    // ...

    public function filters(Request $request)
    {
        return [
            new EnumFilter('user_type', UserType::class),

            new EnumFilter('user_permissions', UserPermissions::class),

            // With optional filter name:
            (new EnumFilter('user_type', UserType::class))
                ->name('Type of user'),

             // With optional default value:
            (new EnumFilter('user_type', UserType::class))
                ->default(UserType::Administrator),
        ];
    }
}
```

Alternatively, you may wish to use the provided Nova Boolean filter (which is also compatible with both the `Enum` and `FlaggedEnum` fields):

```
namespace App\Nova;

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

class Example extends Resource
{
    // ...

    public function filters(Request $request)
    {
        return [
            new EnumBooleanFilter('user_type', UserType::class),

            new EnumBooleanFilter('user_permissions', UserPermissions::class),

            // With optional filter name:
            (new EnumBooleanFilter('user_type', UserType::class))
                ->name('Type of user'),

            // With optional default values:
            (new EnumBooleanFilter('user_type', UserType::class))
                ->default([
                    UserType::Administrator,
                    UserType::Moderator,
                ]),

            // When filtering a FlaggedEnum, it will default to filtering
            // by ANY flags, however you may wish to filter by ALL flags:
            (new EnumBooleanFilter('user_permissions', UserPermissions::class))
                ->filterAllFlags(),
        ];
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Matthew Poulter](https://github.com/mdpoulter)
- [Ben Sampson](https://github.com/BenSampo)
- [atymic](https://github.com/atymic)
- [Robin D'Arcy](https://github.com/rdarcy1)
- [Antoni Siek](https://github.com/ImJustToNy)
- [All Contributors](../../contributors)

Package skeleton based on [spatie/skeleton-php](https://github.com/spatie/skeleton-php).

About us
--------

[](#about-us)

SimpleSquid is a small web development and design company based in Valkenburg, Netherlands.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance46

Moderate activity, may be stable

Popularity50

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 87.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~106 days

Recently: every ~212 days

Total

20

Last Release

417d ago

Major Versions

v1.2.0 → v2.0.02020-07-08

v2.7.0 → v3.0.02022-11-29

PHP version history (6 changes)v1.0.2PHP &gt;=7.1.0

v1.0.3PHP ^7.3

v2.2.0PHP ^7.3|^8.0

v3.0.0PHP ^8.0

v3.2.0PHP ^8.1

v3.3.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/e90efcfce673cabc08f0101ee076b8060508c33e7693c048d58e44e4a53b2300?d=identicon)[simplesquid](/maintainers/simplesquid)

---

Top Contributors

[![mdpoulter](https://avatars.githubusercontent.com/u/1091085?v=4)](https://github.com/mdpoulter "mdpoulter (74 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (1 commits)")[![BenSampo](https://avatars.githubusercontent.com/u/1488068?v=4)](https://github.com/BenSampo "BenSampo (1 commits)")[![brand7n](https://avatars.githubusercontent.com/u/1302681?v=4)](https://github.com/brand7n "brand7n (1 commits)")[![dees040](https://avatars.githubusercontent.com/u/5390555?v=4)](https://github.com/dees040 "dees040 (1 commits)")[![ImJustToNy](https://avatars.githubusercontent.com/u/5730766?v=4)](https://github.com/ImJustToNy "ImJustToNy (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![rdarcy1](https://avatars.githubusercontent.com/u/15962421?v=4)](https://github.com/rdarcy1 "rdarcy1 (1 commits)")[![remxcode](https://avatars.githubusercontent.com/u/3363540?v=4)](https://github.com/remxcode "remxcode (1 commits)")[![trippo](https://avatars.githubusercontent.com/u/497169?v=4)](https://github.com/trippo "trippo (1 commits)")[![asugai](https://avatars.githubusercontent.com/u/2228791?v=4)](https://github.com/asugai "asugai (1 commits)")[![vpratfr](https://avatars.githubusercontent.com/u/2526465?v=4)](https://github.com/vpratfr "vpratfr (1 commits)")

---

Tags

enumenum-fieldlaravellaravel-enumlaravel-novalaravel-nova-fieldnovalaravelenumfieldnovasimplesquidnova-enum-field

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/simplesquid-nova-enum-field/health.svg)

```
[![Health](https://phpackages.com/badges/simplesquid-nova-enum-field/health.svg)](https://phpackages.com/packages/simplesquid-nova-enum-field)
```

###  Alternatives

[datomatic/nova-enum-field

A Laravel Nova PHP 8.1 enum field with filters

20134.2k](/packages/datomatic-nova-enum-field)[alexwenzel/nova-dependency-container

A Laravel Nova 4 form container for grouping fields that depend on other field values.

461.0M2](/packages/alexwenzel-nova-dependency-container)[sietse85/nova-button

(Nova 4+) A Laravel Nova package for adding buttons to your resources.

37347.3k](/packages/sietse85-nova-button)[optimistdigital/nova-notes-field

This Laravel Nova package adds a notes field to Nova's arsenal of fields.

52139.5k](/packages/optimistdigital-nova-notes-field)[outl1ne/nova-color-field

A Laravel Nova Color Picker field.

26249.4k](/packages/outl1ne-nova-color-field)[simplesquid/nova-advanced-number-field

A Laravel Nova field which adds additional functionality to the default Number field.

11162.7k1](/packages/simplesquid-nova-advanced-number-field)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
