您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

BudgetStatus.php 791B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Enums\Accounting;
  3. use Filament\Support\Contracts\HasColor;
  4. use Filament\Support\Contracts\HasLabel;
  5. enum BudgetStatus: string implements HasColor, HasLabel
  6. {
  7. case Draft = 'draft';
  8. case Active = 'active';
  9. case Closed = 'closed';
  10. public function getLabel(): ?string
  11. {
  12. return $this->name;
  13. }
  14. public function getColor(): string | array | null
  15. {
  16. return match ($this) {
  17. self::Draft => 'gray',
  18. self::Active => 'success',
  19. self::Closed => 'warning',
  20. };
  21. }
  22. public function isEditable(): bool
  23. {
  24. return in_array($this, [self::Draft, self::Active]);
  25. }
  26. public static function editableStatuses(): array
  27. {
  28. return [self::Draft, self::Active];
  29. }
  30. }