simedkom/app/Enums/ContentType.php

45 lines
971 B
PHP

<?php
namespace App\Enums;
use App\Traits\Enum\WithComment;
use App\Traits\Enum\WithValue;
use Filament\Support\Contracts\HasLabel;
enum ContentType: int implements HasLabel
{
use WithComment, WithValue;
case FOTO = 1;
case TEXT = 2;
case GRAPHIC = 3;
case VIDEO = 4;
public function getLabel(): ?string
{
return match ($this) {
self::FOTO => 'Foto',
self::TEXT => 'Teks',
self::GRAPHIC => 'Grafis',
self::VIDEO => 'Video',
};
}
public function getColor(): string
{
return match ($this) {
self::FOTO => 'info',
self::TEXT => 'success',
self::GRAPHIC => 'warning',
self::VIDEO => 'danger',
};
}
public static function options(): array
{
return collect(self::cases())
->mapWithKeys(fn ($case) => [$case->value => $case->getLabel()])
->toArray();
}
}