<?php

namespace App\Http\Resources;

use App\Http\Resources\CollateralDetailResource;
use Illuminate\Http\Resources\Json\JsonResource;

class LoanCollateralDetailResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        return [
            'id'                    => $this->id,
            'loan_id'               => $this->id,
            'loan_code'             => $this->loan_code,
            'client_name'           => $this->client->name,
            'co_name'               => $this->co->name,
            'client_code'           => $this->client->code,
            'client_phone'          => $this->client->phone,
            'branch_name'           => $this->branchs->name_km??'',
            'CollateralDetailResource'=> CollateralDetailResource::collection(($this->collateralDetails)),
        ];

}


}
