mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-27 16:34:27 +00:00
order module (code needs cleaning up)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?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')
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user