Files
portal/app/Http/Resources/CompanyResource.php
T
omair saleh 5fb880ef83 large commit
2020-10-22 12:46:06 +08:00

31 lines
916 B
PHP

<?php
namespace App\Http\Resources;
use App\Classes\ValueObjects\Constants\AccountStatus;
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)
{
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' => AccountStatus::STATUS[$this->status],
'delivery_address' => new AddressResource($this->deliveryAddress),
'contact' => new ContactResource($this->contacts->first())
];
}
}