brokeyourbike/enum-casts-laravel

Cast attributes to Enum

0.1.2 2023-05-14 22:28 UTC

This package is auto-updated.

Last update: 2024-12-20 14:56:04 UTC


README

Latest Stable Version Total Downloads Maintainability Test Coverage

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

License

Mozilla Public License v2.0