PHP code example of orkhanahmadov / eloquent-enum-cast
1. Go to this page and download the library: Download orkhanahmadov/eloquent-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/ */
orkhanahmadov / eloquent-enum-cast example snippets
namespace App\Enums;
use MyCLabs\Enum\Enum;
class Role extends Enum
{
private const ADMIN = 1;
private const USER = 2;
}
namespace App\Enums;
use Orkhanahmadov\EloquentEnumCast\EnumCast;
class Role extends EnumCast
{
private const ADMIN = 1;
private const USER = 2;
}
use App\Enums\Role;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $casts = [
'role' => Role::class,
];
}