43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
use App\Filament\Support\CheerfulNotification;
|
|
use App\Traits\Enum\WithComment;
|
|
use App\Traits\Enum\WithValue;
|
|
use Filament\Support\Contracts\HasLabel;
|
|
|
|
enum NewsStatus: int implements HasLabel
|
|
{
|
|
use WithComment, WithValue;
|
|
|
|
case DRAFT = 1;
|
|
case PUBLISHED = 2;
|
|
case ARCHIVED = 3;
|
|
|
|
public function getLabel(): ?string
|
|
{
|
|
return match ($this) {
|
|
self::DRAFT => CheerfulNotification::getByKey('enum.news_status.draft'),
|
|
self::PUBLISHED => CheerfulNotification::getByKey('enum.news_status.published'),
|
|
self::ARCHIVED => CheerfulNotification::getByKey('enum.news_status.archived'),
|
|
};
|
|
}
|
|
|
|
public function getColor(): string|array|null
|
|
{
|
|
return match ($this) {
|
|
self::DRAFT => 'warning',
|
|
self::PUBLISHED => 'success',
|
|
self::ARCHIVED => 'gray',
|
|
};
|
|
}
|
|
|
|
public static function options(): array
|
|
{
|
|
return collect(self::cases())
|
|
->mapWithKeys(fn ($case) => [$case->value => $case->getLabel()])
|
|
->toArray();
|
|
}
|
|
}
|