trypost/app/Enums/Post/Status.php

40 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2026-01-15 01:13:44 +00:00
<?php
declare(strict_types=1);
namespace App\Enums\Post;
2026-01-15 01:13:44 +00:00
enum Status: string
2026-01-15 01:13:44 +00:00
{
case Draft = 'draft';
case Scheduled = 'scheduled';
case Publishing = 'publishing';
case Published = 'published';
2026-01-15 17:24:39 +00:00
case PartiallyPublished = 'partially_published';
2026-01-15 01:13:44 +00:00
case Failed = 'failed';
public function label(): string
{
return match ($this) {
self::Draft => __('posts.status.draft'),
self::Scheduled => __('posts.status.scheduled'),
self::Publishing => __('posts.status.publishing'),
self::Published => __('posts.status.published'),
self::PartiallyPublished => __('posts.status.partially_published'),
self::Failed => __('posts.status.failed'),
2026-01-15 01:13:44 +00:00
};
}
public function color(): string
{
return match ($this) {
self::Draft => 'gray',
self::Scheduled => 'blue',
self::Publishing => 'yellow',
self::Published => 'green',
2026-01-15 17:24:39 +00:00
self::PartiallyPublished => 'orange',
2026-01-15 01:13:44 +00:00
self::Failed => 'red',
};
}
}