Implemented repository mapper, and venta show
This commit is contained in:
20
app/src/Model/Proyecto/Elemento.php
Normal file
20
app/src/Model/Proyecto/Elemento.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Proyecto;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Elemento extends Ideal\Model
|
||||
{
|
||||
public string $descripcion;
|
||||
public string $abreviacion;
|
||||
public int $orden;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'descripcion' => $this->descripcion,
|
||||
'abreviacion' => $this->abreviacion,
|
||||
'orden' => $this->orden
|
||||
]);
|
||||
}
|
||||
}
|
@ -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()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
8
app/src/Model/Proyecto/TipoTipologia.php
Normal file
8
app/src/Model/Proyecto/TipoTipologia.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Proyecto;
|
||||
|
||||
use Incoviba\Model\Tipo;
|
||||
|
||||
class TipoTipologia extends Tipo
|
||||
{
|
||||
}
|
20
app/src/Model/Proyecto/Tipologia.php
Normal file
20
app/src/Model/Proyecto/Tipologia.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Proyecto;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Tipologia extends Ideal\Model
|
||||
{
|
||||
public ProyectoTipoUnidad $proyectoTipoUnidad;
|
||||
public TipoTipologia $tipoTipologia;
|
||||
public int $cantidad;
|
||||
public Elemento $elemento;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'cantidad' => $this->cantidad,
|
||||
'elemento' => $this->elemento
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user