<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class CobroDTView extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            "idCobro"           => strval($this->idCobro),
            "numCobro"          => substr(strval($this->idCobro), -7),
            "dateCobro"         => date("Y-m-d H:i:s",strtotime($this->dateCobro)),
            "dateCobroLite"     => date("d-m-y",strtotime($this->dateCobro)),
            "origenCobro"       => $this->origenCobro,
            "nameOrigenCobro"   => $this->nameOrigenCobro,
            "typeCobro"         => $this->typeCobro,
            "nameTypeCobro"     => $this->nameTypeCobro,
            "idNP"              => strval($this->idNP),
            "numNP"             => substr(strval($this->idNP), -7),
            "idE"               => strval($this->idE),
            "idEUser"           => strval($this->idEUser),
            "nameEUser"         => $this->nameE,
            "idCobrosLista"     => strval($this->idCobrosLista),
            "numCobrosLista"    => substr(strval($this->idCobrosLista), -7),
            "errorCobro"        => $this->errorCobro,
            "estadoCobro"       => $this->estadoCobro,
            "codEdif"           => $this->codEdifCuota,
            "codApto"           => $this->codAptoCuota,
            "refItem"           => (($this->mesDT<10?'0':'').strval($this->mesDT)).'.'.strval($this->anoDT),
            "montoItem"         => number_format($this->montoDT_cc, 2, ',', '.').($this->idMoneda_cc==1001?'Bs':'$'),
        ];

    }
}
