<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class DispatchGuideDetailResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id'          => $this->id,
            'idticket'    => $this->idticket,
            'idproduct'   => $this->idproduct,
            'quantity'    => $this->quantity,
            'ticket'      => $this->whenLoaded('ticket', function () {
                return [
                    'n_document' => $this->ticket->n_document,
                    'status'     => $this->ticket->status,
                ];
            }),
        ];
    }
}
