123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Models\Enums;
- use App\Models\Asset;
- use App\Models\Plan;
- use App\Models\Project;
- use App\Models\Requirement;
- use App\Models\Task;
- use App\Services\History\Detector\DetectorContact;
- use App\Services\History\Detector\ProjectDetector;
- use App\Services\History\Detector\RequirementDetector;
- enum ActionObjectType: string
- {
- case ASSET = "asset";
- case PROJECT = "project";
- case REQUIREMENT="requirement";
- case TASK = "task";
- case PLAN = "plan";
- public function modelBuilder(): \Illuminate\Database\Eloquent\Builder
- {
- return match ($this) {
- self::ASSET => Asset::query(),
- self::PROJECT => Project::query(),
- self::TASK => Task::query(),
- self::PLAN => Plan::query(),
- self::REQUIREMENT => Requirement::query(),
- };
- }
- public function nameField(): string
- {
- return match ($this) {
- self::ASSET, self::PROJECT, self::TASK => "name",
- self::PLAN, self::REQUIREMENT => "title",
- default => "name",
- };
- }
- public function detectorClassName(): ?string
- {
- return match ($this) {
- ActionObjectType::PROJECT => ProjectDetector::class,
- ActionObjectType::REQUIREMENT => RequirementDetector::class,
- default => null
- };
- }
- }
|