Download the PHP package erikaraujo/filament-enum-attributes without Composer
On this page you can find all versions of the php package erikaraujo/filament-enum-attributes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download erikaraujo/filament-enum-attributes
More information about erikaraujo/filament-enum-attributes
Files in erikaraujo/filament-enum-attributes
Package filament-enum-attributes
Short Description Traits for Enums to allow for using Attributes instead of get methods for Filament enums
License MIT
Homepage https://github.com/erikaraujo/filament-enum-attributes
Informations about the package filament-enum-attributes
Filament Enum Attributes
Enum traits to allow the use of attributes in Filament Enums.
Installation
You can install the package via composer:
Usage
First, you need to import and use the Enum traits in your Filament enum class:
Or you can import all traits by simply doing:
Now, instead of coding the default filament get methods (getColor(), getIcon() and getLabel()) as per the documentation, you may simply use the #[Color], #[Icon] and #[Label] attributes in your enum cases.
See example below:
Make sure everything is imported:
You can also pass a boolean translate param to both the Label and Description attributes if you want to translate the string using the laravel helper.
So, the following:
Will be evaluated as __('descriptions.suits.spades').
Testing
To execute the tests, just run the composer scriopt:
If you want to check on the coverage, run:
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.