PHP code example of rvxlab / laravel-enum-cast

1. Go to this page and download the library: Download rvxlab/laravel-enum-cast library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rvxlab / laravel-enum-cast example snippets


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,
    ];
}