Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Frequency.php 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace App\Enums\Accounting;
  3. use App\Enums\Concerns\ParsesEnum;
  4. use Filament\Support\Contracts\HasLabel;
  5. enum Frequency: string implements HasLabel
  6. {
  7. use ParsesEnum;
  8. case Daily = 'daily';
  9. case Weekly = 'weekly';
  10. case Monthly = 'monthly';
  11. case Yearly = 'yearly';
  12. case Custom = 'custom';
  13. public function getLabel(): ?string
  14. {
  15. return $this->name;
  16. }
  17. public function getOptions(): array
  18. {
  19. return match ($this) {
  20. self::Weekly => [
  21. 1 => 'Monday',
  22. 2 => 'Tuesday',
  23. 3 => 'Wednesday',
  24. 4 => 'Thursday',
  25. 5 => 'Friday',
  26. 6 => 'Saturday',
  27. 7 => 'Sunday',
  28. ],
  29. self::Monthly, self::Yearly => [
  30. 1 => 'First',
  31. -1 => 'Last',
  32. 2 => '2nd',
  33. 3 => '3rd',
  34. 4 => '4th',
  35. 5 => '5th',
  36. 6 => '6th',
  37. 7 => '7th',
  38. 8 => '8th',
  39. 9 => '9th',
  40. 10 => '10th',
  41. 11 => '11th',
  42. 12 => '12th',
  43. 13 => '13th',
  44. 14 => '14th',
  45. 15 => '15th',
  46. 16 => '16th',
  47. 17 => '17th',
  48. 18 => '18th',
  49. 19 => '19th',
  50. 20 => '20th',
  51. 21 => '21st',
  52. 22 => '22nd',
  53. 23 => '23rd',
  54. 24 => '24th',
  55. 25 => '25th',
  56. 26 => '26th',
  57. 27 => '27th',
  58. 28 => '28th',
  59. 29 => '29th',
  60. 30 => '30th',
  61. 31 => '31st',
  62. ],
  63. default => [],
  64. };
  65. }
  66. public function isDaily(): bool
  67. {
  68. return $this === self::Daily;
  69. }
  70. public function isWeekly(): bool
  71. {
  72. return $this === self::Weekly;
  73. }
  74. public function isMonthly(): bool
  75. {
  76. return $this === self::Monthly;
  77. }
  78. public function isYearly(): bool
  79. {
  80. return $this === self::Yearly;
  81. }
  82. public function isCustom(): bool
  83. {
  84. return $this === self::Custom;
  85. }
  86. }