<?php

namespace App\Http\Resources;

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

class ReservationView extends JsonResource
{
    public static $wrap = '';

    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        $this->resource->load([
            'vehicle' => function ($query) {
                $query->withTrashed();
            },
            'vehicle.primaryMediaUse.media',
        ]);
        $this->resource->payment_reference = $this->resource->invoice?->payments?->first()->reference;
        return parent::toArray($request);
    }
}
