ActionObjectType.php 760 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Models\Enums;
  3. use App\Models\Asset;
  4. use App\Models\Plan;
  5. use App\Models\Project;
  6. use App\Models\Task;
  7. enum ActionObjectType: string
  8. {
  9. case ASSET = "asset";
  10. case PROJECT = "project";
  11. case TASK = "task";
  12. case PLAN = "plan";
  13. public function modelBuilder(): \Illuminate\Database\Eloquent\Builder
  14. {
  15. return match ($this) {
  16. self::ASSET => Asset::query(),
  17. self::PROJECT => Project::query(),
  18. self::TASK => Task::query(),
  19. self::PLAN => Plan::query(),
  20. };
  21. }
  22. public function nameField(): string
  23. {
  24. return match ($this) {
  25. self::ASSET, self::PROJECT, self::TASK => "name",
  26. self::PLAN => "title",
  27. };
  28. }
  29. }