<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class CollectGoodLoanResource extends JsonResource
{
   
    public function toArray($request)
    {
        return [
            'id'                  => $this->id,
            'loan_id'             => $this->loan_id,
            'currency_id'         => $this->currency_id,
            'payment_date'        => $this->payment_date,
            'principal'           => $this->principal,
            'risk_per_month'      => $this->risk_per_month,
            'maintenance_per_month'=> $this->maintenance_per_month,
            'interest_per_month'  => $this->interest_per_month,
            'payment_per_month'   => $this->payment_per_month,
            'received'            => $this->received,
            'unreceived'          => $this->unreceived,
            'total_penalty'       => 0,
            'loan_code'           => $this->loan->loan_code,
            'client_name'         => $this->client->name,
            'client_phone'        => $this->client->phone,
            'guarantor_name'      => $this->client->guarantors->name??'',
            'co_name'             => $this->co->name,
            'loan_out'            => $this->loan->loan_out??0,
            'total_loan_balance'  => $this->loan->loan_balance??0,
            'balance_principal'   => $this->loan->balance_principal??0,
            'village'             => $this->client->village_id!=null?'ភូមិ'.$this->client->village_kh:'',
        ];
    }
}
