mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 04:23:59 +00:00
36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Classes\ValueObjects\Constants\AccountStatus;
|
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
use App\Classes\ValueObjects\Constants\DocumentType;
|
|
use App\Models\CompanyConnections;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class CompanyResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
dd(CompanyConnections::where('module_one', $this->modules->first()->id)->first()->marking);
|
|
return [
|
|
'id' => $this->id,
|
|
'account_no' => $this->reference_no,
|
|
'marking' => CompanyConnections::where('module_one', $this->modules->first()->id)->first()->marking,
|
|
'name' => $this->name,
|
|
'type' => $this->type,
|
|
'status' => (int) $this->status,
|
|
'delivery_address' => new AddressResource($this->deliveryAddress),
|
|
'contact' => new ContactResource($this->contacts->first()),
|
|
'total_orders' => count($this->orders),
|
|
'identification' => new DocumentResource($this->whenLoaded('documents', $this->documents->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->first())),
|
|
];
|
|
}
|
|
}
|