<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class LoanCollateralReource 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,
            'status'            =>  $this->status,
            'date_made'         =>  $this->date_made,
            'client_id'         =>  $this->client_id,
            'collateral_id'     =>  $this->collateral_id,
            'client_name'       =>  $this->client->name??"",
            'loan_code'         =>  $this->loan->loan_code??"",
            'installment_date'  =>  $this->loan->installment_date??"",
            'number'            =>  $this->collateral_detail->number??"",
            'pawn_type'         =>  $this->collateral_detail->pawn_type??"",
            'price_market'      =>  $this->collateral_detail->price_market??"",
            'collateral_name'   =>  $this->collateral_detail->collateral_name??"",
        ];
    }
}
