2023-07-28 16:22:20 -04:00
|
|
|
<?php
|
|
|
|
namespace Incoviba\Model\Venta;
|
|
|
|
|
|
|
|
use Incoviba\Common\Ideal;
|
|
|
|
|
|
|
|
class Propiedad extends Ideal\Model
|
|
|
|
{
|
|
|
|
public array $unidades;
|
|
|
|
|
|
|
|
public function departamentos(): array
|
|
|
|
{
|
2023-10-20 19:03:29 -03:00
|
|
|
return array_values(array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'departamento';}));
|
2023-07-28 16:22:20 -04:00
|
|
|
}
|
|
|
|
public function estacionamientos(): array
|
|
|
|
{
|
2023-10-20 19:03:29 -03:00
|
|
|
return array_values(array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'estacionamiento';}));
|
2023-07-28 16:22:20 -04:00
|
|
|
}
|
|
|
|
public function bodegas(): array
|
|
|
|
{
|
2023-10-20 19:03:29 -03:00
|
|
|
return array_values(array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'bodega';}));
|
2023-07-28 16:22:20 -04:00
|
|
|
}
|
|
|
|
|
2023-08-08 23:53:49 -04:00
|
|
|
protected float $vendible;
|
|
|
|
public function vendible(): float
|
|
|
|
{
|
|
|
|
return array_reduce($this->departamentos(), function(float $sum, Unidad $unidad) {
|
|
|
|
return $sum + $unidad->proyectoTipoUnidad->vendible();
|
|
|
|
}, 0);
|
|
|
|
}
|
|
|
|
|
2023-07-28 16:22:20 -04:00
|
|
|
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()
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|