31 lines
545 B
PHP
31 lines
545 B
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
enum Gender: int
|
|
{
|
|
case MALE = 1;
|
|
case FEMALE = 0;
|
|
|
|
public function label(): string
|
|
{
|
|
return match ($this) {
|
|
self::MALE => 'Male',
|
|
self::FEMALE => 'Female',
|
|
};
|
|
}
|
|
|
|
public function color(): string
|
|
{
|
|
return match ($this) {
|
|
self::MALE => 'primary',
|
|
self::FEMALE => 'success',
|
|
};
|
|
}
|
|
|
|
public static function values(): array
|
|
{
|
|
return array_map(fn ($case) => $case->value, self::cases());
|
|
}
|
|
}
|