<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use App\Danoral\U;


class CobroDetalle extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            "idCuota"           => strval($this->idCuota),
            "ref"               => is_null($this->ref)?'':$this->ref,
            "tcCobro_idTC"      => is_null($this->tcCobro_idTC)?'':strval($this->tcCobro_idTC),
            "tcCobro_valor"     => is_null($this->tcCobro_valor)?'':number_format($this->tcCobro_valor, 4, ',', '.'),
            "tcCobro_date"      => is_null($this->tcCobro_date)?'':date("d.m.y",strtotime($this->tcCobro_date)),
            "tcCobro_isPeriodoGracia" => $this->tcCobro_isPeriodoGracia,

            "idDT"              => strval($this->idDT),
            "typeDT"            => $this->typeDT,
            "anoDT"             => is_null($this->anoDT)?'':$this->anoDT,
            "mesDT"             => is_null($this->mesDT)?'':U::getMesTxt($this->mesDT),
            "montoItemCobro"    => number_format($this->montoItemCobro, 2, ',', '.'),
            "montoDT"           => number_format($this->montoDT, 2, ',', '.'),
            "idMonedaDT"        => $this->idMonedaDT,
            
            "idCFP"             => strval($this->idCFP),
            "indexCFP"          => $this->indexCFP,
            "fechaCFP"          => date("d/m/Y",strtotime($this->fechaCFP)),
            "montoTotalCFP"     => number_format($this->montoTotalCFP, 2, ',', '.'),
            "montoCFP"          => number_format($this->montoCFP, 2, ',', '.'),
            "idMonedaCFP"       => intval($this->idMonedaCFP),
            
            "modoLineaDT"       => $this->modoLineaDT,
            "modoLineaCFP"      => $this->modoLineaCFP,
            "isPagado"          => $this->isPagado,
        ];

    }
}
