brokeyourbike / enum-casts-laravel
Cast attributes to Enum
Fund package maintenance!
brokeyourbike
Open Collective
Requires
- php: ^7.4 || ^8.0
- illuminate/contracts: ^8
- myclabs/php-enum: ^1.8
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.4
- illuminate/database: ^8
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-20 14:16:28 UTC
README
Cast attributes to Enum
Installation
composer require brokeyourbike/enum-casts-laravel
Usage
use Illuminate\Database\Eloquent\Model; use BrokeYourBike\EnumCasts\EnumCast; use BrokeYourBike\EnumCasts\NullableEnumCast; class Order extends Model { protected $casts = [ 'state' => EnumCast::class . ':' . StateEnum::class, 'state_nullable' => NullableEnumCast::class . ':' . StateEnum::class, ]; }
Authors
- Ivan Stasiuk | Twitter | LinkedIn | stasi.uk