{"id":40872097,"url":"https://github.com/simplesquid/nova-enum-field","last_synced_at":"2026-01-22T00:41:28.411Z","repository":{"id":35102517,"uuid":"207021436","full_name":"simplesquid/nova-enum-field","owner":"simplesquid","description":"An enum field and filters for Laravel Nova.","archived":false,"fork":false,"pushed_at":"2025-03-27T17:43:21.000Z","size":294,"stargazers_count":52,"open_issues_count":0,"forks_count":28,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-14T20:27:52.273Z","etag":null,"topics":["enum","enum-field","laravel","laravel-enum","laravel-nova","laravel-nova-field","nova"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simplesquid.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-07T20:19:24.000Z","updated_at":"2025-03-27T17:40:43.000Z","dependencies_parsed_at":"2024-06-18T16:49:38.574Z","dependency_job_id":null,"html_url":"https://github.com/simplesquid/nova-enum-field","commit_stats":{"total_commits":77,"total_committers":14,"mean_commits":5.5,"dds":"0.35064935064935066","last_synced_commit":"ed978fcb4c4f1a9c0129578e5f0b690d07a1424e"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/simplesquid/nova-enum-field","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesquid%2Fnova-enum-field","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesquid%2Fnova-enum-field/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesquid%2Fnova-enum-field/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesquid%2Fnova-enum-field/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplesquid","download_url":"https://codeload.github.com/simplesquid/nova-enum-field/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesquid%2Fnova-enum-field/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28648460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T21:29:11.980Z","status":"ssl_error","status_checked_at":"2026-01-21T21:24:31.872Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["enum","enum-field","laravel","laravel-enum","laravel-nova","laravel-nova-field","nova"],"created_at":"2026-01-22T00:41:27.856Z","updated_at":"2026-01-22T00:41:28.406Z","avatar_url":"https://github.com/simplesquid.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# An enum field for Laravel Nova\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/simplesquid/nova-enum-field.svg?style=flat-square)](https://packagist.org/packages/simplesquid/nova-enum-field)\n[![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)\n[![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)\n[![MIT License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Total Downloads](https://img.shields.io/packagist/dt/simplesquid/nova-enum-field.svg?style=flat-square)](https://packagist.org/packages/simplesquid/nova-enum-field)\n\nLaravel 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.\n\n![Screenshot of the enum field](https://github.com/simplesquid/nova-enum-field/raw/main/docs/screenshot.png)\n\n## Installation\n\nYou can install this package in a Laravel app that uses [Nova](https://nova.laravel.com) via composer:\n\n```bash\ncomposer require simplesquid/nova-enum-field\n```\n\n## Setup\n\nIt 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:\n\n```php\nuse App\\Enums\\UserType;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Example extends Model\n{\n    protected $casts = [\n        'user_type' =\u003e UserType::class,\n    ];\n}\n```\n\n## Usage\n\nYou can use the `Enum` field in your Nova resource like this:\n\n```php\nnamespace App\\Nova;\n\nuse App\\Enums\\UserType;\nuse SimpleSquid\\Nova\\Fields\\Enum\\Enum;\n\nclass Example extends Resource\n{\n    // ...\n\n    public function fields(Request $request)\n    {\n        return [\n            // ...\n\n            Enum::make('User Type')-\u003eattach(UserType::class),\n\n            // ...\n        ];\n    }\n}\n```\n\n### Flagged Enums\n\nYou can use the `FlaggedEnum` field in your Nova resource like this (see [Flagged/Bitwise Enum](https://github.com/BenSampo/laravel-enum#flaggedbitwise-enum) setup):\n\n```php\nnamespace App\\Nova;\n\nuse App\\Enums\\UserPermissions;\nuse SimpleSquid\\Nova\\Fields\\Enum\\FlaggedEnum;\n\nclass Example extends Resource\n{\n    // ...\n\n    public function fields(Request $request)\n    {\n        return [\n            // ...\n\n            FlaggedEnum::make('User Permissions')-\u003eattach(UserPermissions::class),\n\n            // ...\n        ];\n    }\n}\n```\n\n### Filters\n\nIf 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:\n\n```php\nnamespace App\\Nova;\n\nuse App\\Enums\\UserPermissions;\nuse App\\Enums\\UserType;\nuse SimpleSquid\\Nova\\Fields\\Enum\\EnumFilter;\n\nclass Example extends Resource\n{\n    // ...\n\n    public function filters(Request $request)\n    {\n        return [\n            new EnumFilter('user_type', UserType::class),\n            \n            new EnumFilter('user_permissions', UserPermissions::class),\n            \n            // With optional filter name:\n            (new EnumFilter('user_type', UserType::class))\n                -\u003ename('Type of user'),\n                \n             // With optional default value:\n            (new EnumFilter('user_type', UserType::class))\n                -\u003edefault(UserType::Administrator),\n        ];\n    }\n}\n```\n\nAlternatively, you may wish to use the provided Nova Boolean filter (which is also compatible with both the `Enum` and `FlaggedEnum` fields):\n\n```php\nnamespace App\\Nova;\n\nuse App\\Enums\\UserPermissions;\nuse App\\Enums\\UserType;\nuse SimpleSquid\\Nova\\Fields\\Enum\\EnumBooleanFilter;\n\nclass Example extends Resource\n{\n    // ...\n\n    public function filters(Request $request)\n    {\n        return [\n            new EnumBooleanFilter('user_type', UserType::class),\n            \n            new EnumBooleanFilter('user_permissions', UserPermissions::class),\n            \n            // With optional filter name:\n            (new EnumBooleanFilter('user_type', UserType::class))\n                -\u003ename('Type of user'),\n                \n            // With optional default values:\n            (new EnumBooleanFilter('user_type', UserType::class))\n                -\u003edefault([\n                    UserType::Administrator,\n                    UserType::Moderator,\n                ]),\n            \n            // When filtering a FlaggedEnum, it will default to filtering\n            // by ANY flags, however you may wish to filter by ALL flags:\n            (new EnumBooleanFilter('user_permissions', UserPermissions::class))\n                -\u003efilterAllFlags(),\n        ];\n    }\n}\n```\n\n## Testing\n\n``` bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Matthew Poulter](https://github.com/mdpoulter)\n- [Ben Sampson](https://github.com/BenSampo)\n- [atymic](https://github.com/atymic)\n- [Robin D'Arcy](https://github.com/rdarcy1)\n- [Antoni Siek](https://github.com/ImJustToNy)\n- [All Contributors](../../contributors)\n\nPackage skeleton based on [spatie/skeleton-php](https://github.com/spatie/skeleton-php).\n\n## About us\n\nSimpleSquid is a small web development and design company based in Valkenburg, Netherlands.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplesquid%2Fnova-enum-field","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplesquid%2Fnova-enum-field","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplesquid%2Fnova-enum-field/lists"}