Implemented repository mapper, and venta show

This commit is contained in:
Juan Pablo Vial
2023-08-08 23:53:49 -04:00
parent ef30ae67d2
commit 59825259b6
111 changed files with 2766 additions and 612 deletions

View File

@ -15,6 +15,8 @@ class ProyectoTipoUnidad extends Ideal\Model
public float $terraza;
public string $descripcion;
public array $tipologias;
public function superficie(): float
{
return array_reduce([$this->util, $this->logia, $this->terraza], function($sum, $item) {return $sum + $item;}, 0);
@ -23,6 +25,23 @@ class ProyectoTipoUnidad extends Ideal\Model
{
return array_reduce([$this->util, $this->logia, $this->terraza / 2], function($sum, $item) {return $sum + $item;}, 0);
}
public function tipologia(): string
{
if (isset($this->tipologias) and count($this->tipologias) > 0) {
$temp = [...$this->tipologias];
usort($temp, function(Tipologia $a, Tipologia $b) {
$el = $a->elemento->orden - $b->elemento->orden;
if ($el === 0) {
return strcmp($a->elemento->abreviacion, $b->elemento->abreviacion);
}
return $el;
});
return implode('/', array_map(function(Tipologia $tipologia) {
return $tipologia->cantidad . $tipologia->elemento->abreviacion;
}, $temp));
}
return $this->abreviacion;
}
public function jsonSerialize(): mixed
{
@ -36,7 +55,8 @@ class ProyectoTipoUnidad extends Ideal\Model
'terraza' => $this->terraza,
'superficie' => $this->superficie(),
'vendible' => $this->vendible(),
'descripcion' => $this->descripcion
'descripcion' => $this->descripcion,
'tipologia' => $this->tipologia()
]);
}
}