Model ticket link counterparts explicitly
linter / quality (pull_request) Successful in 3m5s
tests / ci (8.4) (pull_request) Failing after 1m41s

This commit is contained in:
2026-05-23 10:29:22 +00:00
parent d60c33fa7c
commit 486994e441
22 changed files with 312 additions and 66 deletions
+5 -2
View File
@@ -18,16 +18,19 @@ class TicketLinkResource extends JsonResource
{
if ($this->resource instanceof TicketLink) {
$currentTicketId = (int) ($this->resource->getAttribute('current_ticket_id') ?? 0);
$linkedTicket = $this->source_ticket_id === $currentTicketId
$isSourceTicket = $this->source_ticket_id === $currentTicketId;
$linkedTicket = $isSourceTicket
? $this->targetTicket
: $this->sourceTicket;
$ticketLinkType = TicketLinkTypeResource::make($this->ticketLinkType)->resolve();
$ticketLinkType['label'] = $this->ticketLinkType->labelForSource($isSourceTicket);
return [
'id' => $this->id,
'linked_ticket' => TicketReferenceResource::make($linkedTicket)->resolve(),
'source_ticket_id' => $this->source_ticket_id,
'target_ticket_id' => $this->target_ticket_id,
'ticket_link_type' => TicketLinkTypeResource::make($this->ticketLinkType)->resolve(),
'ticket_link_type' => $ticketLinkType,
'ticket_link_type_id' => $this->ticket_link_type_id,
'created_at' => $this->created_at?->toISOString(),
'updated_at' => $this->updated_at?->toISOString(),