1. Go to this page and download the library: Download spatie/laravel-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.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
spatie / laravel-enum example snippets
// a Laravel specific base classuseSpatie\Enum\Laravel\Enum;
/**
* @method static self DRAFT()
* @method static self PREVIEW()
* @method static self PUBLISHED()
* @method static self ARCHIVED()
*/finalclassStatusEnumextendsEnum{}
useSpatie\Enum\Laravel\Http\EnumRequest;
$enums = [
// cast the status key independent of it's data set'status' => StatusEnum::class,
// cast the status only in the request query params
EnumRequest::REQUEST_QUERY => [
'status' => StatusEnum::class,
],
// cast the status only in the request post data
EnumRequest::REQUEST_REQUEST => [
'status' => StatusEnum::class,
],
// cast the status only in the request route params
EnumRequest::REQUEST_ROUTE => [
'status' => StatusEnum::class,
],
];