codex ticket rework

This commit is contained in:
2026-04-13 01:04:06 +02:00
parent b3f2cc3afd
commit 182ed018d1
45 changed files with 1208 additions and 420 deletions
@@ -2,6 +2,8 @@
namespace App\Http\Requests;
use App\Actions\Permissions\PermissionService;
use App\Enums\Permission;
use App\Models\Project;
use App\Models\Ticket;
use App\Models\TicketType;
@@ -33,6 +35,8 @@ class UpdateProjectTicketRequest extends FormRequest
return [
'acceptance_criteria' => ['nullable', 'string'],
'assignee_user_id' => ['nullable', 'integer', Rule::exists('users', 'id')],
'author_user_id' => ['nullable', 'integer', Rule::exists('users', 'id')],
'blocked_comment' => ['nullable', 'string'],
'description' => ['nullable', 'string'],
'field_values' => ['array'],
@@ -61,7 +65,7 @@ class UpdateProjectTicketRequest extends FormRequest
Rule::exists('ticket_types', 'id')->where('project_id', $project->id),
],
'title' => ['required', 'string', 'max:255'],
'story_points' => ['nullable', 'integer', 'gt:0'],
'story_points' => ['nullable', 'integer', 'min:0'],
];
}
@@ -73,7 +77,7 @@ class UpdateProjectTicketRequest extends FormRequest
return [
function (Validator $validator): void {
/** @var array<string, mixed> $validated */
$validated = $this->validated();
$validated = $this->safe()->all();
/** @var Project $project */
$project = $this->route('project');
@@ -81,6 +85,9 @@ class UpdateProjectTicketRequest extends FormRequest
/** @var Ticket $ticket */
$ticket = $this->route('ticket');
$canManageProject = app(PermissionService::class)
->allows($this->user(), Permission::ProjectAdmin, $project);
$parentTicketId = Arr::get($validated, 'parent_ticket_id');
if ($parentTicketId !== null) {
@@ -95,8 +102,8 @@ class UpdateProjectTicketRequest extends FormRequest
->with('ticketType')
->find($parentTicketId);
if ($parentTicket !== null && $parentTicket->ticketType?->system_key !== 'parent') {
$validator->errors()->add('parent_ticket_id', 'Only tickets of type Parent can be selected as a parent.');
if ($parentTicket !== null && ! $parentTicket->ticketType?->is_parent) {
$validator->errors()->add('parent_ticket_id', 'Only tickets with a parent-enabled type can be selected as a parent.');
return;
}
@@ -114,15 +121,23 @@ class UpdateProjectTicketRequest extends FormRequest
->find($requestedTicketTypeId);
if (
$requestedTicketType?->system_key !== 'parent'
! $requestedTicketType?->is_parent
&& $ticket->childTickets()->exists()
) {
$validator->errors()->add('ticket_type_id', 'Tickets with child tickets must keep a Parent type.');
$validator->errors()->add('ticket_type_id', 'Tickets with child tickets must keep a parent-enabled type.');
}
if (Arr::get($validated, 'is_blocked', false) && blank(Arr::get($validated, 'blocked_comment'))) {
$validator->errors()->add('blocked_comment', 'Blocked tickets require a blocker comment.');
}
if (
Arr::exists($validated, 'author_user_id')
&& (int) Arr::get($validated, 'author_user_id') !== (int) $ticket->author_user_id
&& ! $canManageProject
) {
$validator->errors()->add('author_user_id', 'Only project admins can change the author.');
}
},
];
}