estados)) { $this->estados = $this->runFactory('estados'); } return $this->estados; } protected Model\Inmobiliaria\Cuenta\Estado $currentEstado; public function currentEstado(): Model\Inmobiliaria\Cuenta\Estado { if (!isset($this->currentEstado)) { $estados = $this->getEstados(); if (count($estados) === 0) { throw new EmptyResult('Current Estado Cuenta'); } usort($estados, function(Model\Inmobiliaria\Cuenta\Estado $a, Model\Inmobiliaria\Cuenta\Estado $b) { return $a->id - $b->id; }); $this->currentEstado = end($estados); } return $this->currentEstado; } public function jsonSerialize(): mixed { return array_merge(parent::jsonSerialize(), [ 'inmobiliaria_rut' => $this->inmobiliaria->rut, 'banco' => $this->banco, 'cuenta' => $this->cuenta ]); } }