<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class DanoralCliente 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:'',
            'rifE'          => isset($datose->rif_numero->value)?$datose->rif_numero->value:'',
            'direccionE'    => isset($datose->direccion_general->value)?$datose->direccion_general->value:'',
            'typeE_str'     => $this->getTypeEL(),
            'iconE'         => $this->getIconEL(),

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

        ];
    }
}
