DEleted function in request and changed the way the controller uses it,
linter / quality (pull_request) Successful in 1m13s
tests / ci (8.4) (pull_request) Failing after 1m15s

This commit is contained in:
Eric Peters
2026-04-03 16:50:00 +02:00
parent 2c1a0cbff3
commit 1c355c20b4
27 changed files with 285 additions and 263 deletions
@@ -10,6 +10,7 @@ use App\Models\Ticket;
use App\Models\TicketLink;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
class ProjectTicketLinkController extends Controller
@@ -24,25 +25,31 @@ class ProjectTicketLinkController extends Controller
Project $project,
Ticket $ticket,
): RedirectResponse {
$user = $request->user();
abort_unless(
$this->projectPermissionService->userHasPermission($request->user(), $project, 'edit'),
$this->projectPermissionService->userHasPermission($user, $project, 'edit'),
403,
);
$validated = $request->validated();
$linkedTicketId = Arr::get($validated, 'linked_ticket_id');
$ticketLinkTypeId = Arr::get($validated, 'ticket_link_type_id');
$linkedTicket = Ticket::query()
->where('project_id', $project->id)
->findOrFail($request->linkedTicketId());
->findOrFail($linkedTicketId);
[$sourceTicketId, $targetTicketId] = $this->normalizeTicketPair($ticket->id, $linkedTicket->id);
$ticketLink = DB::transaction(function () use ($linkedTicket, $request, $sourceTicketId, $targetTicketId, $ticket): TicketLink {
$ticketLink = DB::transaction(function () use ($linkedTicket, $user, $ticketLinkTypeId, $sourceTicketId, $targetTicketId, $ticket): TicketLink {
$ticketLink = TicketLink::query()->updateOrCreate(
[
'source_ticket_id' => $sourceTicketId,
'target_ticket_id' => $targetTicketId,
],
[
'ticket_link_type_id' => $request->ticketLinkTypeId(),
'ticket_link_type_id' => $ticketLinkTypeId,
],
);
@@ -50,7 +57,7 @@ class ProjectTicketLinkController extends Controller
$this->createTicketWorklogEntry->handle(
$ticket,
$request->user(),
$user,
'link_updated',
"Linked {$linkedTicket->ticket_key} as {$ticketLink->ticketLinkType->label}.",
[
@@ -61,7 +68,7 @@ class ProjectTicketLinkController extends Controller
$this->createTicketWorklogEntry->handle(
$linkedTicket,
$request->user(),
$user,
'link_updated',
"Linked {$ticket->ticket_key} as {$ticketLink->ticketLinkType->label}.",
[
@@ -83,8 +90,10 @@ class ProjectTicketLinkController extends Controller
Ticket $ticket,
TicketLink $ticketLink,
): RedirectResponse {
$user = $request->user();
abort_unless(
$this->projectPermissionService->userHasPermission($request->user(), $project, 'edit'),
$this->projectPermissionService->userHasPermission($user, $project, 'edit'),
403,
);
@@ -101,12 +110,12 @@ class ProjectTicketLinkController extends Controller
$label = $ticketLink->ticketLinkType->label;
DB::transaction(function () use ($label, $linkedTicket, $request, $ticket, $ticketLink): void {
DB::transaction(function () use ($label, $linkedTicket, $user, $ticket, $ticketLink): void {
$ticketLink->delete();
$this->createTicketWorklogEntry->handle(
$ticket,
$request->user(),
$user,
'link_removed',
"Removed {$label} link to {$linkedTicket->ticket_key}.",
[
@@ -117,7 +126,7 @@ class ProjectTicketLinkController extends Controller
$this->createTicketWorklogEntry->handle(
$linkedTicket,
$request->user(),
$user,
'link_removed',
"Removed {$label} link to {$ticket->ticket_key}.",
[