Model ticket link counterparts explicitly
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user