<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class LateResource extends JsonResource
{
   
    public function toArray($request)
    {
        return [
            'id'              => $this->id,
            'loan_code'       => $this->loan->loan_code,
            'client_code'     => $this->client->code,
            'client_name'     => $this->client->name,
            'client_phone'    => $this->client->phone,
            'address'         => $this->client->village_id!=null?$this->client->village->name_km.','.$this->client->commune->name_km.','.$this->client->district->name_km:'',
            'client_id'       => $this->client_id,
            'co_name'         => $this->co->name,
            'currency_name'   => $this->currency_id==1?'រៀល':'ដុល្លារ',
            'level_loan'      => $this->loan->level_loan,
            'principal_late'  => $this->principal_late??0,
            'interest_late'   => $this->interest_late??0,
            'maintenance_late'=> $this->maintenance_late??0,
            'risk_late'       => $this->risk_late??0,
            'received_late'   => $this->received_late??0,
            'unreceived_late' => $this->unreceived_late??0,
            'total_late'      => $this->total_late['total_late']??0,
            'date_late'       => $this->total_late['start_date']??'',
        ];
    }
}