feat(enum): create enum for media module

This commit is contained in:
Yoga Pangestu 2025-12-04 15:27:22 +07:00
parent 9aa585d8c9
commit 500f934deb
2 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,32 @@
<?php
namespace App\Enums;
use App\Traits\Enum\WithComment;
use App\Traits\Enum\WithValue;
enum MediaClassification: int
{
use WithComment, WithValue;
case LOCAL = 1;
case REGIONAL = 2;
case NATIONAL = 3;
public function label()
{
return match ($this) {
self::LOCAL => 'Lokal',
self::REGIONAL => 'Regional',
self::NATIONAL => 'Nasional',
};
}
public static function options(): array
{
return array_combine(
array_map(fn ($status) => $status->value, self::cases()),
array_map(fn ($status) => $status->label(), self::cases())
);
}
}

34
app/Enums/MediaType.php Normal file
View File

@ -0,0 +1,34 @@
<?php
namespace App\Enums;
use App\Traits\Enum\WithComment;
use App\Traits\Enum\WithValue;
enum MediaType: int
{
use WithComment, WithValue;
case ONLINE = 1;
case PRINT = 2;
case RADIO = 3;
case TELEVISION = 4;
public function label()
{
return match ($this) {
self::ONLINE => 'Online',
self::PRINT => 'Cetak',
self::RADIO => 'Radio',
self::TELEVISION => 'Televisi',
};
}
public static function options(): array
{
return array_combine(
array_map(fn ($status) => $status->value, self::cases()),
array_map(fn ($status) => $status->label(), self::cases())
);
}
}