-menambahkan method comment -menyesuaikan label UserStatus -menambahkan method icon UserStatus
48 lines
1.0 KiB
PHP
48 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
enum UserStatus: int
|
|
{
|
|
case ACTIVE = 1;
|
|
case INACTIVE = 2;
|
|
case SUSPENDED = 3;
|
|
|
|
public function label(): string
|
|
{
|
|
return match ($this) {
|
|
self::ACTIVE => 'Aktif',
|
|
self::INACTIVE => 'Tidak Aktif',
|
|
self::SUSPENDED => 'Suspend',
|
|
};
|
|
}
|
|
|
|
public function color(): string
|
|
{
|
|
return match ($this) {
|
|
self::ACTIVE => 'primary',
|
|
self::INACTIVE => 'warning',
|
|
self::SUSPENDED => 'danger',
|
|
};
|
|
}
|
|
|
|
public function icon(): string
|
|
{
|
|
return match ($this) {
|
|
self::ACTIVE => 'check-circle',
|
|
self::INACTIVE => 'x-circle',
|
|
self::SUSPENDED => 'ban',
|
|
};
|
|
}
|
|
|
|
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()));
|
|
}
|
|
}
|