<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

use App\Http\Resources\Banco as BancoResources;


class Ingreso extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'idIngreso'             => strval($this->idIngreso),
            'idBanco'               => $this->idBanco,
            'ref'                   => $this->refIngreso,       
            'type'                  => $this->typeIngreso,
            'date'                  => date("Y-m-d",strtotime($this->dateIngreso)),
            'dateTxt'               => date("d.m.y",strtotime($this->dateIngreso)),
            'monto'                 => $this->montoDT,
            'montoTxt'              => number_format($this->montoDT, 2, ',', '.') .' '. ($this->banco->idMoneda==1001?'Bs':'$'),
            'idBT'                  => strval($this->idBT),

            'idDTIngreso'           => strval($this->idDTIngreso),
            'idDTIngresoCobro'      => strval($this->idDTIngresoCobro),
            
            'idPlanilla'            => $this->idPlanilla,

            'banco'                 => new BancoResources($this->banco),
            'infoBT'                => $this->infoBT,
            'infoCobro'             => $this->infoCobro,
        
        ];
    }
}


