Search update and optimization
This commit is contained in:
@ -66,7 +66,7 @@ class Venta extends Ideal\Model
|
||||
|
||||
public function proyecto(): Proyecto
|
||||
{
|
||||
return $this->propiedad()->departamentos()[0]->proyectoTipoUnidad->proyecto;
|
||||
return $this->propiedad()->proyecto();
|
||||
}
|
||||
|
||||
protected float $valor_util;
|
||||
|
@ -2,22 +2,40 @@
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Propiedad extends Ideal\Model
|
||||
{
|
||||
public array $unidades;
|
||||
|
||||
protected array $departamentos;
|
||||
public function departamentos(): array
|
||||
{
|
||||
return array_values(array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'departamento';}));
|
||||
if (!isset($this->departamentos)) {
|
||||
$this->departamentos = array_values(array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'departamento';}));
|
||||
}
|
||||
return $this->departamentos;
|
||||
}
|
||||
protected array $estacionamientos;
|
||||
public function estacionamientos(): array
|
||||
{
|
||||
return array_values(array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'estacionamiento';}));
|
||||
if (!isset($this->estacionamientos)) {
|
||||
$this->estacionamientos = array_values(array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'estacionamiento';}));
|
||||
}
|
||||
return $this->estacionamientos;
|
||||
}
|
||||
protected array $bodegas;
|
||||
public function bodegas(): array
|
||||
{
|
||||
return array_values(array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'bodega';}));
|
||||
if (!isset($this->bodegas)) {
|
||||
$this->bodegas = array_values(array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'bodega';}));
|
||||
}
|
||||
return $this->bodegas;
|
||||
}
|
||||
|
||||
public function proyecto(): Model\Proyecto
|
||||
{
|
||||
return $this->unidades[0]->proyectoTipoUnidad->proyecto;
|
||||
}
|
||||
|
||||
protected float $vendible;
|
||||
@ -46,6 +64,7 @@ class Propiedad extends Ideal\Model
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return [
|
||||
'unidades' => $this->unidades,
|
||||
'departamentos' => $this->departamentos(),
|
||||
'estacionamientos' => $this->estacionamientos(),
|
||||
'bodegas' => $this->bodegas(),
|
||||
|
@ -46,7 +46,7 @@ class Unidad extends Ideal\Model
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
$output = array_merge(parent::jsonSerialize(), [
|
||||
'subtipo' => $this->subtipo,
|
||||
'piso' => $this->piso,
|
||||
'descripcion' => $this->descripcion,
|
||||
@ -54,5 +54,10 @@ class Unidad extends Ideal\Model
|
||||
'proyecto_tipo_unidad' => $this->proyectoTipoUnidad,
|
||||
'prorrateo' => $this->prorrateo
|
||||
]);
|
||||
if (isset($this->precios)) {
|
||||
$output['precios'] = $this->precios;
|
||||
$output['current_precio'] = $this->currentPrecio;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user