Laravel Backed Enums is an awesome package that supercharges your PHP8-backed enums with superpowers like localization support and fluent comparison methods. The enum you create must implement the BackedEnum interface and also use the IsBackedEnum trait. The interface is required for Laravel to cast your enum correctly and the trait is what gives your enum its superpowers. use Webfox\LaravelBackedEnums\BackedEnum; use Webfox\LaravelBackedEnums\IsBackedEnum; enum VolumeUnitEnum: string implements BackedEnum { use IsBackedEnum; case GRAMS = "GRAMS"; case KILOGRAMS = "KILOGRAMS"; }

If you do not specify a label in the lang file these methods will return the value assigned to the enum inside the enum file.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners