mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 12:34:03 +00:00
8a28eb1790
This reverts merge request !5
42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Classes\Constants;
|
|
use App\Classes\Modules\Documents\ListDocuments;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use App\Models\AddressBook;
|
|
|
|
class Company extends JsonResource
|
|
{
|
|
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
$billing = AddressBook::where('company_id', $this->id)
|
|
->where('billing', true)->first();
|
|
|
|
return [
|
|
'id' => $this->id,
|
|
'name' => $this->name,
|
|
'marking' => $this->marking,
|
|
'email' => $this->email,
|
|
'registration_no' => $this->registration_no,
|
|
'tax_no' => $this->tax_no,
|
|
'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,
|
|
'registration_certificate' => (new ListDocuments(Constants::MODULE_TYPES['company'], $this->id, 'registration_certificate'))->execute(),
|
|
'logo' => (new ListDocuments(Constants::MODULE_TYPES['company'], $this->id, 'logo'))->execute()
|
|
];
|
|
}
|
|
}
|