48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
![]() |
<?php
|
||
|
namespace Incoviba\Model\Venta;
|
||
|
|
||
|
use Incoviba\Common\Ideal;
|
||
|
|
||
|
class Propiedad extends Ideal\Model
|
||
|
{
|
||
|
public array $unidades;
|
||
|
|
||
|
public function departamentos(): array
|
||
|
{
|
||
|
return array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'departamento';});
|
||
|
}
|
||
|
public function estacionamientos(): array
|
||
|
{
|
||
|
return array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'estacionamiento';});
|
||
|
}
|
||
|
public function bodegas(): array
|
||
|
{
|
||
|
return array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'bodega';});
|
||
|
}
|
||
|
|
||
|
public function summary(): string
|
||
|
{
|
||
|
return implode(' - ', array_merge(
|
||
|
array_map(function(Unidad $unidad) {
|
||
|
return $unidad->descripcion;
|
||
|
}, $this->departamentos()),
|
||
|
array_map(function(Unidad $unidad) {
|
||
|
return "E{$unidad->descripcion}";
|
||
|
}, $this->estacionamientos()),
|
||
|
array_map(function(Unidad $unidad) {
|
||
|
return "B{$unidad->descripcion}";
|
||
|
}, $this->bodegas())
|
||
|
));
|
||
|
}
|
||
|
|
||
|
public function jsonSerialize(): mixed
|
||
|
{
|
||
|
return [
|
||
|
'departamentos' => $this->departamentos(),
|
||
|
'estacionamientos' => $this->estacionamientos(),
|
||
|
'bodegas' => $this->bodegas(),
|
||
|
'summary' => $this->summary()
|
||
|
];
|
||
|
}
|
||
|
}
|