simedkom/app/Enums/IssueSentiment.php

47 lines
1.1 KiB
PHP

<?php
namespace App\Enums;
use App\Traits\Enum\WithComment;
use App\Traits\Enum\WithValue;
use Filament\Support\Colors\Color;
use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;
enum IssueSentiment: string implements HasColor, HasLabel
{
use WithComment, WithValue;
case POSITIVE = 'positive';
case NEGATIVE = 'negative';
case NEUTRAL = 'neutral';
case CRISIS = 'krisis';
public function getLabel(): ?string
{
return match ($this) {
self::POSITIVE => 'Positif',
self::NEGATIVE => 'Negatif',
self::NEUTRAL => 'Netral',
self::CRISIS => 'Krisis',
};
}
public function getColor(): string|array|null
{
return match ($this) {
self::POSITIVE => Color::Green,
self::NEGATIVE => Color::Red,
self::NEUTRAL => Color::Gray,
self::CRISIS => Color::Orange,
};
}
public static function options(): array
{
return collect(self::cases())
->mapWithKeys(fn ($case) => [$case->value => $case->getLabel()])
->toArray();
}
}