> */ public function rules(): array { return [ 'ids' => [ 'required', 'array', ], 'ids.*' => [ 'string', 'uuid', ], 'changes' => [ 'required', 'array', ], // ID of the organization member that the time entry should belong to 'changes.member_id' => [ 'string', ExistsEloquent::make(Member::class, null, function (Builder $builder): Builder { /** @var Builder $builder */ return $builder->whereBelongsTo($this->organization, 'organization'); })->uuid(), ], // ID of the project that the time entry should belong to 'changes.project_id' => [ 'nullable', 'string', 'required_with:task_id', ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder { /** @var Builder $builder */ return $builder->whereBelongsTo($this->organization, 'organization'); })->uuid(), ], // ID of the task that the time entry should belong to 'changes.task_id' => [ 'nullable', 'string', ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder { /** @var Builder $builder */ return $builder->whereBelongsTo($this->organization, 'organization'); })->uuid(), ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder { /** @var Builder $builder */ return $builder->whereBelongsTo($this->organization, 'organization') ->where('project_id', $this->input('changes.project_id')); })->uuid()->withMessage(__('validation.task_belongs_to_project')), ], // Whether time entry is billable 'changes.billable' => [ 'boolean', ], // Description of time entry 'changes.description' => [ 'nullable', 'string', 'max:500', ], // List of tag IDs 'changes.tags' => [ 'nullable', 'array', ], 'changes.tags.*' => [ 'string', ExistsEloquent::make(Tag::class, null, function (Builder $builder): Builder { /** @var Builder $builder */ return $builder->whereBelongsTo($this->organization, 'organization'); })->uuid(), ], ]; } }