123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Models\Enums;
- use App\Models\Action;
- use App\Models\Asset;
- use App\Models\Container;
- use App\Models\Plan;
- use App\Models\Project;
- use App\Models\Requirement;
- use App\Models\Task;
- enum ShareFileObjectType: string
- {
- case ASSET = "asset";
- case PROJECT = "project";
- case REQUIREMENT = "requirement";
- case TASK = "task";
- case ACTION = "action";
- case PLAN = "plan";
- case CONTAINER = "container";
- public function modelBuilder(): \Illuminate\Database\Eloquent\Builder
- {
- return match ($this) {
- self::ASSET => Asset::query(),
- self::PROJECT => Project::query(),
- self::TASK => Task::query(),
- self::REQUIREMENT => Requirement::query(),
- self::ACTION => Action::query(),
- self::PLAN => Plan::query(),
- self::CONTAINER => Container::query(),
- };
- }
- public function modelBuilderAllowed(string $id = null): \Illuminate\Database\Eloquent\Builder
- {
- return match ($this) {
- self::ASSET => Asset::query(),
- self::PROJECT => Project::query()->allowed($id),
- self::TASK => Task::query()->allowed($id),
- self::REQUIREMENT => Requirement::query(),
- self::ACTION => Action::query(),
- self::PLAN => Plan::query(),
- self::CONTAINER => Container::query()->allowed($id),
- };
- }
- }
|