<?php

namespace App\Http\Resources;

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

class CuotaEdif extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'codEdif'                   => strval($this->codEdif),
            'codApto'                   => strval($this->codApto),
            'idCuota'                   => strval($this->idCuota),
            'idCond'                    => strval($this->idCond),
            'idE'                       => strval($this->idE),
            'ano'                       => $this->anoDT,
            'mes'                       => U::getMesTxt($this->mesDT),
            'monto'                     => number_format($this->montoDT, 2, ',', '.'),
            'monto_valor'               => floatval($this->montoDT),
            'idMoneda'                  => $this->idMoneda,
            'tcEmision_dateVen'         => $this->tcEmision_dateVen,
            'tcEmision_valor'           => floatval($this->tcEmision_valor),
            'tcEmision_date'            => is_null($this->tcEmision_date)?null:date("d.m.y",strtotime($this->tcEmision_date)),
            'tcCobro_isPeriodoGracia'   => $this->tcCobro_isPeriodoGracia,
            'tcCobro_valor'             => floatval($this->tcCobro_valor),
            'tcCobro_date'              => is_null($this->tcCobro_date)?null:date("d.m.y",strtotime($this->tcCobro_date)),
            'tcCobro_montoCuota'        => is_null($this->tcCobro_montoCuota)?null:number_format($this->tcCobro_montoCuota, 2, ',', '.'),
            'tcCobro_idMoneda'          => $this->tcCobro_idMoneda,
            'montoOrigen'               => floatval($this->montoOrigen),
            'isCobrado'                 => !is_null($this->idDTCuotaCobro),
        ];
    }
}
