mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-22 05:54:08 +00:00
31 lines
993 B
PHP
31 lines
993 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
|
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,
|
|
'company_module' => new CompanyModuleResource($this->companyModule),
|
|
'warehouse' => new CompanyModuleResource($this->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee),
|
|
'address' => new AddressResource($this->addresses()->first()),
|
|
'created_at' => $this->created_at->format('d-m-Y')
|
|
];
|
|
}
|
|
}
|