ActionObjectType.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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\Requirement;
  7. use App\Models\Task;
  8. use App\Services\History\Detector\DetectorContact;
  9. use App\Services\History\Detector\ProjectDetector;
  10. enum ActionObjectType: string
  11. {
  12. case ASSET = "asset";
  13. case PROJECT = "project";
  14. case REQUIREMENT="requirement";
  15. case TASK = "task";
  16. case PLAN = "plan";
  17. public function modelBuilder(): \Illuminate\Database\Eloquent\Builder
  18. {
  19. return match ($this) {
  20. self::ASSET => Asset::query(),
  21. self::PROJECT => Project::query(),
  22. self::TASK => Task::query(),
  23. self::PLAN => Plan::query(),
  24. self::REQUIREMENT => Requirement::query(),
  25. };
  26. }
  27. public function nameField(): string
  28. {
  29. return match ($this) {
  30. self::ASSET, self::PROJECT, self::TASK => "name",
  31. self::PLAN => "title",
  32. };
  33. }
  34. public function detectorClassName(): ?string
  35. {
  36. return match ($this) {
  37. ActionObjectType::PROJECT => ProjectDetector::class,
  38. default => null
  39. };
  40. }
  41. }