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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners