Initial commit
This commit is contained in:
38
laravel/app/Enums/TaskStatus.php
Normal file
38
laravel/app/Enums/TaskStatus.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum TaskStatus: string
|
||||
{
|
||||
case PENDING = 'pending';
|
||||
case IN_PROGRESS = 'in_progress';
|
||||
case COMPLETED = 'completed';
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_map(fn($case) => $case->value, self::cases());
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return [
|
||||
self::PENDING->value => 'В ожидании',
|
||||
self::IN_PROGRESS->value => 'В процессе',
|
||||
self::COMPLETED->value => 'Завершена',
|
||||
];
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::PENDING => 'В ожидании',
|
||||
self::IN_PROGRESS => 'В процессе',
|
||||
self::COMPLETED => 'Завершена',
|
||||
};
|
||||
}
|
||||
|
||||
public function isCompleted(): bool
|
||||
{
|
||||
return $this === self::COMPLETED;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user