rvxlab / laravel-enum-cast
This package is abandoned and no longer maintained.
No replacement package was suggested.
Enum casts for Laravel
1.1.1
2022-02-13 01:23 UTC
Requires
- php: ^7.3|^8.0
- myclabs/php-enum: ^1.8
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18
- nunomaduro/larastan: ^0.7.0
- orchestra/testbench: ^6.13
- phpunit/phpunit: ^9.5
- rregeer/phpunit-coverage-check: ^0.3.1
This package is auto-updated.
Last update: 2022-02-13 01:23:50 UTC
README
Laravel Enum Cast
This package is no longer maintained
Native enums are supported as of PHP 8.1 and Laravel 8.71.0, as such I will no longer be maintaining this package.
Enum cast for Laravel Models using myclabs/php-enum.
Installation
Install through composer
composer require rvxlab/laravel-enum-cast
Usage
Add the CastsEnums
trait to your model, add the EnumCast
class to the $casts
array and create an $enums
array to tell which enum should be used.
class CarMake extends \MyCLabs\Enum\Enum { public const VOLKSWAGEN = 'volkswagen'; public const BMW = 'bmw'; } class Car extends \Illuminate\Database\Eloquent\Model { use \RVxLab\LaravelEnumCast\CastsEnums; protected $casts = [ 'make' => \RVxLab\LaravelEnumCast\EnumCast::class, ]; protected $enums = [ 'make' => CarMake::class, ]; }
That's it, you're all set!
License
This project uses the MIT License