Files
izyim/app/Http/Resources/Order.php
T
Omair Saleh 43a9e0ca03 large commit
2019-05-18 12:14:31 +08:00

42 lines
1.4 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 Illuminate\Http\Resources\Json\JsonResource;
use App\Models\AddressBook;
class Order extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
$addressBook = AddressBook::find($this->address_id)->first();
return [
'id' => $this->id,
'company_id' => $this->company_id,
'marking' => $this->marking,
'forwarder_id' => $this->forwarder_id,
'supplier_id' => $this->supplier_id,
'warehouse_id' => $this->warehouse_id,
'address' => new \App\Http\Resources\AddressBook($addressBook),
'current_step' => $this->current_step,
'complete' => (float)$this->complete,
'date' => $this->created_at->format('d/m/Y'),
'steps' => [
'details' => (new GetStep())->execute($this->current_step),
'attachments' => (new StepAttachments())->execute($this->id, $this->current_step)
],
'details' => (new ListsOrderHistory())->execute($this->id, $this->created_at, $this->complete, $this->updated_at)
];
}
}