first commit
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum CharacterStatus: string
|
||||
{
|
||||
case ACTIVE = 'active';
|
||||
case IN_HOSPITAL = 'in_hospital';
|
||||
case IN_JAIL = 'in_jail';
|
||||
case DEAD = 'dead';
|
||||
|
||||
/**
|
||||
* Get all status values as an array
|
||||
*/
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display name for a status
|
||||
*/
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::ACTIVE => 'Active',
|
||||
self::IN_HOSPITAL => 'In Hospital',
|
||||
self::IN_JAIL => 'In Jail',
|
||||
self::DEAD => 'Dead',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if character can perform actions
|
||||
*/
|
||||
public function canAct(): bool
|
||||
{
|
||||
return $this === self::ACTIVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color class for the status badge
|
||||
*/
|
||||
public function color(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::ACTIVE => 'bg-green-500',
|
||||
self::IN_HOSPITAL => 'bg-red-500',
|
||||
self::IN_JAIL => 'bg-yellow-500',
|
||||
self::DEAD => 'bg-gray-500',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user