mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 12:34:01 +00:00
31 lines
803 B
PHP
31 lines
803 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Models\Address;
|
|
use App\Models\Company;
|
|
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,
|
|
'marking' => $this->order_number,
|
|
'company' => Company::where('id', $this->company_id)->first(),
|
|
'warehouse_id' => $this->warehouse_id,
|
|
'address' => new AddressResource(Address::where('id', $this->address_id)->first()),
|
|
'complete' => (int)$this->complete,
|
|
'date' => $this->created_at->format('d/m/Y')
|
|
];
|
|
}
|
|
|
|
}
|