| 12345678910111213141516171819202122232425262728 |
- <?php
-
- namespace App\Enums;
-
- enum ProductStatus: string
- {
- /** Saved, but hidden from shoppers. */
- case Draft = 'draft';
-
- /** Shown in the store. */
- case Active = 'active';
-
- public function label(): string
- {
- return match ($this) {
- self::Draft => 'Draft',
- self::Active => 'Active',
- };
- }
-
- /**
- * @return list<array{value: string, label: string}>
- */
- public static function options(): array
- {
- return array_map(fn (self $status) => ['value' => $status->value, 'label' => $status->label()], self::cases());
- }
- }
|