mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 04:24:00 +00:00
49 lines
2.0 KiB
PHP
49 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Classes\Modules\Orders\Services\ListsOrderHistory;
|
|
use App\Classes\Modules\Steps\GetStep;
|
|
use App\Classes\Modules\Steps\StepAttachments;
|
|
use App\Models\OrderStep;
|
|
use App\Http\Resources\OrderStep as OrderStepResource;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use App\Models\AddressBook as AddressBookModel;
|
|
use App\Models\DeliveryArrangement as DeliveryArrangementModel;
|
|
use App\Models\PackingList as PackingListModel;
|
|
use App\Models\ShippingArrangement as ShippingArrangementModel;
|
|
|
|
class Order extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
$addressBook = AddressBookModel::where('id', $this->address_id)->first();
|
|
return [
|
|
'id' => $this->id,
|
|
'marking' => $this->marking,
|
|
'forwarder_id' => $this->forwarder_id,
|
|
'supplier_id' => $this->supplier_id,
|
|
'warehouse_id' => $this->warehouse_id,
|
|
'address' => new AddressBook($addressBook),
|
|
'complete' => (int)$this->complete,
|
|
'date' => $this->created_at->format('d/m/Y'),
|
|
'current_step' => [
|
|
'details' => (new GetStep())->execute($this->current_step),
|
|
'attachments' => (new StepAttachments())->execute($this->id, $this->current_step)
|
|
],
|
|
'steps' => OrderStepResource::collection(OrderStep::where('order_id', $this->id)->orderBy('sequence')->get()),
|
|
'details' => (new ListsOrderHistory())->execute($this->id, $this->created_at, $this->complete, $this->updated_at),
|
|
'packing_list' => new PackingList(PackingListModel::where('order_id', $this->id)->first()),
|
|
'shipping_arrangement' => new ShippingArrangement(ShippingArrangementModel::where('order_id', $this->id)->first()),
|
|
'delivery_arrangement' => new DeliveryArrangement(DeliveryArrangementModel::where('order_id', $this->id)->first())
|
|
];
|
|
}
|
|
|
|
}
|