-menambahkan method comment -menyesuaikan label UserStatus -menambahkan method icon UserStatus
39 lines
847 B
PHP
39 lines
847 B
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
enum EmploymentStatus: int
|
|
{
|
|
case PERMANENT = 1;
|
|
case CONTRACT = 2;
|
|
case INTERN = 3;
|
|
|
|
public function label(): string
|
|
{
|
|
return match ($this) {
|
|
self::PERMANENT => 'Permanent',
|
|
self::CONTRACT => 'Contract',
|
|
self::INTERN => 'Intern',
|
|
};
|
|
}
|
|
|
|
public function color(): string
|
|
{
|
|
return match ($this) {
|
|
self::PERMANENT => 'primary',
|
|
self::CONTRACT => 'warning',
|
|
self::INTERN => 'secondary',
|
|
};
|
|
}
|
|
|
|
public static function values(): array
|
|
{
|
|
return array_map(fn ($case) => $case->value, self::cases());
|
|
}
|
|
|
|
public static function comment(): string
|
|
{
|
|
return implode(', ', array_map(fn ($case) => "{$case->value}: {$case->label()}", self::cases()));
|
|
}
|
|
}
|