simedkom/app/Enums/VerificationStatus.php

47 lines
1.3 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\HasColor;
use Filament\Support\Contracts\HasLabel;
enum VerificationStatus: int implements HasColor, HasLabel
{
use WithComment, WithValue;
case PENDING = 1;
case APPROVED = 2;
case NEED_REVISION = 3;
case REJECTED = 4;
public function getLabel(): ?string
{
return match ($this) {
self::PENDING => CheerfulNotification::getByKey('enum.verification_status.pending'),
self::APPROVED => CheerfulNotification::getByKey('enum.verification_status.approved'),
self::NEED_REVISION => CheerfulNotification::getByKey('enum.verification_status.need_revision'),
self::REJECTED => CheerfulNotification::getByKey('enum.verification_status.rejected'),
};
}
public function getColor(): string|array|null
{
return match ($this) {
self::PENDING => 'warning',
self::APPROVED => 'success',
self::NEED_REVISION => 'info',
self::REJECTED => 'danger',
};
}
public static function options(): array
{
return collect(self::cases())
->mapWithKeys(fn ($case) => [$case->value => $case->getLabel()])
->toArray();
}
}