68 lines
1.6 KiB
PHP
68 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\enum;
|
|
|
|
enum UserLevel: int
|
|
{
|
|
case SUPERADMIN = 9;
|
|
case NORMALUSER = 0;
|
|
case BANNEDUSER = 1;
|
|
|
|
/**
|
|
* Get the user-friendly label for the enum value.
|
|
*/
|
|
public function getLabel(): string
|
|
{
|
|
return match ($this) {
|
|
self::SUPERADMIN => 'Super Admin',
|
|
self::NORMALUSER => 'Normal User',
|
|
self::BANNEDUSER => 'Banned User',
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Get the color for the enum value (for UI display).
|
|
*/
|
|
public function getColor(): string
|
|
{
|
|
return match ($this) {
|
|
self::SUPERADMIN => 'danger', // Red for highest privilege
|
|
self::NORMALUSER => 'success', // Green for regular users
|
|
self::BANNEDUSER => 'warning', // Yellow/Orange for banned users
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Get the icon for the enum value.
|
|
*/
|
|
public function getIcon(): string
|
|
{
|
|
return match ($this) {
|
|
self::SUPERADMIN => 'heroicon-o-shield-check',
|
|
self::NORMALUSER => 'heroicon-o-user',
|
|
self::BANNEDUSER => 'heroicon-o-no-symbol',
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Get all options as array for select fields.
|
|
*/
|
|
public static function getSelectOptions(): array
|
|
{
|
|
return collect(self::cases())->mapWithKeys(fn ($case) => [
|
|
$case->value => $case->getLabel(),
|
|
])->toArray();
|
|
}
|
|
|
|
/**
|
|
* Get the badge configuration for Filament.
|
|
*/
|
|
public function getBadge(): array
|
|
{
|
|
return [
|
|
'name' => $this->getLabel(),
|
|
'color' => $this->getColor(),
|
|
];
|
|
}
|
|
}
|