<?php

namespace App\Http\Resources;

use App\Models\Schedule as ScheduleModel;
use Illuminate\Http\Resources\Json\JsonResource;

class ShippingArrangement extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'container_no' => $this->container_no,
            'seal_no' => $this->seal_no,
            'schedule' => Schedule::collection(ScheduleModel::where('arrangement_id', $this->id)->where('type', 0)->orderBy('created_at', 'desc')->get())
        ];
    }
}
