<?php

namespace App\Http\Resources;

use App\Classes\ValueObjects\Constants\PackingListType;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\RoleTypes;
use App\Models\Order;
use App\Models\PackingList;
use Illuminate\Http\Resources\Json\JsonResource;

class DeliveryPackingListResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $package = $this->packages()->first();

        return [
            'id' => $this->id,
            'claimant_id' => $this->claimant_id,
            'reference' => $this->reference,
            'status' => $this->status,
            'transport' => new TransportResource($this->transports()->first()),
            'type' => $package->type,
            'description' => $package->description,
            'weight' => (float) $package->weight,
            'quantity' => (float) $package->quantity,
        ];
    }
}
