mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 11:51:11 -05:00
80 lines
2.1 KiB
PHP
80 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
enum ParkStatus: string
|
|
{
|
|
case OPERATING = 'OPERATING';
|
|
case CLOSED_TEMP = 'CLOSED_TEMP';
|
|
case CLOSED_PERM = 'CLOSED_PERM';
|
|
case UNDER_CONSTRUCTION = 'UNDER_CONSTRUCTION';
|
|
case DEMOLISHED = 'DEMOLISHED';
|
|
case RELOCATED = 'RELOCATED';
|
|
|
|
/**
|
|
* Get the display label for the status
|
|
*/
|
|
public function label(): string
|
|
{
|
|
return match($this) {
|
|
self::OPERATING => 'Operating',
|
|
self::CLOSED_TEMP => 'Temporarily Closed',
|
|
self::CLOSED_PERM => 'Permanently Closed',
|
|
self::UNDER_CONSTRUCTION => 'Under Construction',
|
|
self::DEMOLISHED => 'Demolished',
|
|
self::RELOCATED => 'Relocated',
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Get Tailwind CSS classes for status badge
|
|
*/
|
|
public function getStatusClasses(): string
|
|
{
|
|
return match($this) {
|
|
self::OPERATING => 'bg-green-100 text-green-800',
|
|
self::CLOSED_TEMP => 'bg-yellow-100 text-yellow-800',
|
|
self::CLOSED_PERM => 'bg-red-100 text-red-800',
|
|
self::UNDER_CONSTRUCTION => 'bg-blue-100 text-blue-800',
|
|
self::DEMOLISHED => 'bg-gray-100 text-gray-800',
|
|
self::RELOCATED => 'bg-purple-100 text-purple-800',
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Check if the park is currently operational
|
|
*/
|
|
public function isOperational(): bool
|
|
{
|
|
return $this === self::OPERATING;
|
|
}
|
|
|
|
/**
|
|
* Check if the park is permanently closed
|
|
*/
|
|
public function isPermanentlyClosed(): bool
|
|
{
|
|
return in_array($this, [self::CLOSED_PERM, self::DEMOLISHED]);
|
|
}
|
|
|
|
/**
|
|
* Check if the park is temporarily closed
|
|
*/
|
|
public function isTemporarilyClosed(): bool
|
|
{
|
|
return $this === self::CLOSED_TEMP;
|
|
}
|
|
|
|
/**
|
|
* Get all status options as an array for forms
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public static function options(): array
|
|
{
|
|
return array_reduce(self::cases(), function ($carry, $status) {
|
|
$carry[$status->value] = $status->label();
|
|
return $carry;
|
|
}, []);
|
|
}
|
|
} |