All notable changes to Enum will be documented in this file.
- Changed use of php8.2 and more only For laravel 10 usage
- Allow usage on php 7.4 and more as php 8 for cross compatibility
- Bumped orchestra to 6 to allow unit test for all php versions
- Fixed check for label duplicates or missing declaration
- Reintroduce getRouteKey to handle router with model + tests
- Full unit tests with 100% coverage
- A laravel command to generate an Enum ``php artisan make:enum`
- examples and a full, readme doc
- Code refactoring for most of the code
- Removed unused code parts
- Set requirements for unit test to laravel 7
- translations are in php files
- An enum used as in a route will now provoque a 404 code instead of generating null enum
- CheckEnumRule nows works properly and has unit tests
- Now if you are using enums in laravel, you have to extend from
BaseEnumRoutableinstead ofBaseEnum. This will allow for enum to be used in routes as a parameter getting them as a controller parameter with implicit binding. - All laravel dependencies have been removed, this allows enum to be used in another project type. The project is now dependency free.
- Validation rule EnumIsValidRule, the constructor needs a BaseEnum class eg: new EnumIsValidRule(ArcadiaMailType::class)
- Unit tests with 0.1.2 changes
- Validation rule EnumIsValidRule, the constructor needs a BaseEnum class eg: new EnumIsValidRule(ArcadiaMailType::class)
- Unit tests with 0.1.2 changes
- Changed toJson to output array with label and value
- Fixed performances issue on toValues and toLabels
- toArray Method now returns an array of BaseEnums this is because php numeric string array indexes to int, this would break origin enum values
-
Enum cast in Models
usage: Put this in your model
use CastsEnums;
protected $enumCasts = [ 'status' => OrderStatus::class // This is a class that extends \Kwaadpepper\Enum\BaseEnum ];