<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use App\Danoral\Entidades\EDatoType;

class EntidadApto 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),
            'codApto'       => isset($datose->cod->value)?$datose->cod->value:'',
            'nameApto'      => isset($datose->name->value)?$datose->name->value:'',
            'codCliente'    => isset($datose->apto_cod_cliente->value)?$datose->name->value:'',
            'alicuota'      => isset($datose->alicuota->value)?$datose->name->value:'',
            'datose'        => $datose,
            'edatos'        => $this->edatos,
        ];
    }
}
