mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 12:34:01 +00:00
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
|
|
use App\Models\Company;
|
|
use App\Models\Address;
|
|
use App\Models\Currency;
|
|
use App\Models\OrderStep;
|
|
use App\Models\SegmentConstant;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class OrderResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'reference' => $this->reference,
|
|
'reference_contract' => (int) $this->type,
|
|
'type' => (int) $this->type,
|
|
'status' => (int) $this->status,
|
|
'current_step' => $this->current_step,
|
|
'company' => new CompanyResource(Company::where('id',$this->companyModule()->first()->company_id)->first()),
|
|
'address' => new AddressResource($this->when($this->has('addresses'), $this->addresses->where('owner_id', $this->id)->first())),
|
|
'order_steps' => OrderStepResource::collection($this->orderSteps()->get()),
|
|
];
|
|
}
|
|
}
|