1. Go to this page and download the library: Download nasyrov/laravel-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/ */
php
$status = new UserStatusEnum(UserStatusEnum::ACTIVE);
$status = UserStatusEnum::ACTIVE();
php
public function getStatusAttribute($attribute) {
return new UserStatusEnum($attribute);
}
php
public function setStatusAttribute(UserStatusEnum $attribute) {
$this->attributes['status'] = $attribute->getValue();
}
php
$this->validate($request, [
'status' => [
'
php
use Nasyrov\Laravel\Enums\Enum as BaseEnum;
abstract class Enum extends BaseEnum
{
/**
* Get the enum labels.
*
* @return array
*/
public static function labels()
{
return static::constants()
->flip()
->map(function ($key) {
// Place your translation strings in `resources/lang/en/enum.php`
return trans(sprintf('enum.%s', strtolower($key)));
})
->all();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.