FileObjectType.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Models\Enums;
  3. use App\Models\Action;
  4. use App\Models\Plan;
  5. use App\Models\Project;
  6. use App\Models\Requirement;
  7. use App\Models\Task;
  8. enum FileObjectType: string
  9. {
  10. case PROJECT = "project";
  11. case REQUIREMENT="requirement";
  12. case TASK = "task";
  13. case ACTION = "action";
  14. case PLAN = "plan";
  15. public function modelBuilder(): \Illuminate\Database\Eloquent\Builder
  16. {
  17. return match ($this) {
  18. self::PROJECT => Project::query(),
  19. self::TASK => Task::query(),
  20. self::REQUIREMENT => Requirement::query(),
  21. self::ACTION => Action::query(),
  22. self::PLAN => Plan::query(),
  23. };
  24. }
  25. public function modelBuilderAllowed(string $id = null): \Illuminate\Database\Eloquent\Builder
  26. {
  27. return match ($this) {
  28. self::PROJECT => Project::query()->allowed($id),
  29. self::TASK => Task::query()->allowed($id),
  30. self::REQUIREMENT => Requirement::query(),
  31. self::ACTION => Action::query(),
  32. self::PLAN => Plan::query(),
  33. };
  34. }
  35. }