Implement ticket details and worklog editing

This commit is contained in:
2026-03-25 08:23:08 +01:00
parent 7e767b0c6c
commit 1ff8f5d68f
25 changed files with 1585 additions and 11 deletions
@@ -0,0 +1,106 @@
<?php
namespace App\Http\Requests;
use App\Models\Project;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Arr;
use Illuminate\Validation\Rule;
class UpdateProjectTicketRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return $this->user() !== null;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|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<int, array{
* ticket_field_definition_id: int,
* value_number?: float|int|string|null,
* value_user_id?: int|string|null
* }>
*/
public function fieldValues(): array
{
/** @var array<int, array{
* ticket_field_definition_id: int,
* value_number?: float|int|string|null,
* value_user_id?: int|string|null
* }> $fieldValues
*/
$fieldValues = $this->validated('field_values', []);
return $fieldValues;
}
}