user() !== null; } /** * Get the validation rules that apply to the request. * * @return array|string> */ public function rules(): array { /** @var Project $project */ $project = $this->route('project'); return [ 'acceptance_criteria' => ['nullable', 'string'], 'description' => ['nullable', 'string'], 'field_values' => ['array'], 'field_values.*' => ['array'], 'field_values.*.ticket_field_definition_id' => [ 'required', 'integer', Rule::exists('ticket_field_definitions', 'id')->where('project_id', $project->id), ], 'field_values.*.value_number' => ['nullable', 'numeric'], 'field_values.*.value_user_id' => ['nullable', 'integer', Rule::exists('users', 'id')], 'ticket_priority_id' => [ 'required', 'integer', Rule::exists('ticket_priorities', 'id')->where('project_id', $project->id), ], 'ticket_type_id' => [ 'required', 'integer', Rule::exists('ticket_types', 'id')->where('project_id', $project->id), ], 'title' => ['required', 'string', 'max:255'], ]; } /** * @return array{ * acceptance_criteria: string|null, * description: string|null, * ticket_priority_id: int, * ticket_type_id: int, * title: string * } */ public function ticketAttributes(): array { /** @var array{ * acceptance_criteria: string|null, * description: string|null, * ticket_priority_id: int, * ticket_type_id: int, * title: string * } $attributes */ $attributes = Arr::only($this->validated(), [ 'acceptance_criteria', 'description', 'ticket_priority_id', 'ticket_type_id', 'title', ]); return $attributes; } /** * @return array */ public function fieldValues(): array { /** @var array $fieldValues */ $fieldValues = $this->validated('field_values', []); return $fieldValues; } }