1. Go to this page and download the library: Download laravel-enso/enums 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/ */
laravel-enso / enums example snippets
return [
'vendors' => ['laravel-enso'],
];
use LaravelEnso\Enums\Services\Enum;
class Roles extends Enum
{
public const Admin = 1;
public const Supervisor = 2;
public const User = 3;
}
use LaravelEnso\Enums\Contracts\Frontend;
use LaravelEnso\Enums\Contracts\Mappable;
use LaravelEnso\Enums\Traits\Select;
enum Status: int implements Frontend, Mappable
{
use Select;
case Draft = 0;
case Published = 1;
public static function registerBy(): string
{
return 'statuses';
}
public function map(): mixed
{
return match ($this) {
self::Draft => 'Draft',
self::Published => 'Published',
};
}
}
use LaravelEnso\Enums\Facades\Enums;
Enums::register([
'roles' => \App\Enums\Roles::class,
]);