mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 12:34:03 +00:00
31 lines
953 B
PHP
31 lines
953 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class Warehouse extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
$billing = $this->addressBook()->where('reference_id', $this->id)->where('type', 2)->where('billing', true)->first();
|
|
return [
|
|
'id' => $this->id,
|
|
'name' => $this->name,
|
|
'email' => $this->email,
|
|
'street_one' => $billing ? $billing->street_one : null,
|
|
'street_two' => $billing ? $billing->street_two : null,
|
|
'city' => $billing ? $billing->city : null,
|
|
'state' => $billing ? $billing->state : null,
|
|
'post_code' => $billing ? $billing->post_code : null,
|
|
'country' => $billing ? $billing->country : null
|
|
];
|
|
}
|
|
}
|