68 lines
1.3 KiB
PHP
68 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Enums;
|
||
|
|
|
||
|
|
use Kwaadpepper\Enum\BaseEnum;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @method static self draft()
|
||
|
|
* @method static self published()
|
||
|
|
* @method static self archived()
|
||
|
|
*/
|
||
|
|
final class PublishedStatus extends BaseEnum
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Enum values
|
||
|
|
*
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
protected static function values(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'draft' => 0,
|
||
|
|
'published' => 1,
|
||
|
|
'archived' => 2
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Enum labels
|
||
|
|
*
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
protected static function labels(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'draft' => trans('enums.draft'),
|
||
|
|
'published' => trans('enums.published'),
|
||
|
|
'archived' => trans('enums.archived')
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Enum classes
|
||
|
|
*
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
protected static function icon(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'draft' => '📝',
|
||
|
|
'published' => '🌍',
|
||
|
|
'archived' => '🗄️'
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param string $attribute
|
||
|
|
* @return integer|string
|
||
|
|
*/
|
||
|
|
public function __get(string $attribute)
|
||
|
|
{
|
||
|
|
if ($attribute === 'icon') {
|
||
|
|
return $this->icon()[$this->getDefinition()] ?? null;
|
||
|
|
}
|
||
|
|
return parent::__get($attribute);
|
||
|
|
}
|
||
|
|
}
|