feat(enum): create enum for media module
This commit is contained in:
parent
9aa585d8c9
commit
500f934deb
32
app/Enums/MediaClassification.php
Normal file
32
app/Enums/MediaClassification.php
Normal 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
34
app/Enums/MediaType.php
Normal 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())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user