mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-21 13:34:00 +00:00
35 lines
919 B
PHP
35 lines
919 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
|
|
use App\Models\Order;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class PackingListBaseResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
//The Base
|
|
$data = [
|
|
'id' => $this->id,
|
|
'claimant_id' => $this->claimant_id,
|
|
'reference' => $this->reference,
|
|
'status' => $this->status,
|
|
'transport' => new TransportResource($this->transports()->first()),
|
|
'type' => $this->type,
|
|
'container' => new ContainerResource($this->containers->first()),
|
|
$this->mergeWhen($this->owner instanceof Order, [
|
|
'order' => New OrderResource($this->owner)
|
|
]),
|
|
];
|
|
return $data;
|
|
}
|
|
}
|