<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class EntidadLite extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $datose = json_decode($this->datose);
        return [
            'idE'           => strval($this->idE),
            'typeE'         => $this->typeE,
            'enableE'       => $this->enableE,
            'idESuper'      => strval($this->idESuper),

            'codESuper'     => isset($this->codESuper)?$this->codESuper:'',
            'codE'          => isset($datose->cod->value)?$datose->cod->value:'',
            'nameE'         => isset($datose->name->value)?$datose->name->value:'',

            'countSubE'     => isset($this->countSubE)?$this->countSubE:'',

            'dolarType'     => isset($datose->edif_dolarizado->value)?$datose->edif_dolarizado->value:'',
            'dolarDesde'    => isset($datose->edif_dolarizado_desde->value)?$datose->edif_dolarizado_desde->value:'',
        ];
    }
}
