1. Go to this page and download the library: Download sakanjo/laravel-easy-enum 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/ */
sakanjo / laravel-easy-enum example snippets
namespace App\Enums;
use SaKanjo\EasyEnum;
enum ExampleEnum: int
{
use EasyEnum;
case Active = 0;
case NOPE = 1;
}
Status::Active->resolveDisplayableValue(); // Active
namespace App\Enums;
use Filament\Support\Contracts\HasLabel;
use SaKanjo\EasyEnum;
enum Status: int implements HasLabel
{
use EasyEnum;
case Active = 0;
case Disabled = 1;
}
use Filament\Forms;
use App\Enums;
Forms\Components\Select::make('status')
->options(Enums\Status::class);
namespace App\Enums;
use Illuminate\Contracts\Support\DeferringDisplayableValue;
use Illuminate\Contracts\Support\Htmlable;
use SaKanjo\EasyEnum;
enum Status: int implements Htmlable // or DeferringDisplayableValue
{
use EasyEnum;
case Active = 0;
case Disabled = 1;
}
<div>
Current status: {{ auth()->user()->status }}
</div>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.