Implemented repository mapper, and venta show
This commit is contained in:
@ -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()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user