43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
![]() |
<?php
|
||
|
namespace Incoviba\Model\Proyecto;
|
||
|
|
||
|
use Incoviba\Common\Ideal;
|
||
|
use Incoviba\Model;
|
||
|
|
||
|
class ProyectoTipoUnidad extends Ideal\Model
|
||
|
{
|
||
|
public Model\Proyecto $proyecto;
|
||
|
public Model\Venta\TipoUnidad $tipoUnidad;
|
||
|
public string $nombre;
|
||
|
public string $abreviacion;
|
||
|
public float $util;
|
||
|
public float $logia;
|
||
|
public float $terraza;
|
||
|
public string $descripcion;
|
||
|
|
||
|
public function superficie(): float
|
||
|
{
|
||
|
return array_reduce([$this->util, $this->logia, $this->terraza], function($sum, $item) {return $sum + $item;}, 0);
|
||
|
}
|
||
|
public function vendible(): float
|
||
|
{
|
||
|
return array_reduce([$this->util, $this->logia, $this->terraza / 2], function($sum, $item) {return $sum + $item;}, 0);
|
||
|
}
|
||
|
|
||
|
public function jsonSerialize(): mixed
|
||
|
{
|
||
|
return array_merge(parent::jsonSerialize(), [
|
||
|
'proyecto' => $this->proyecto,
|
||
|
'tipo_unidad' => $this->tipoUnidad,
|
||
|
'nombre' => $this->nombre,
|
||
|
'abreviacion' => $this->abreviacion,
|
||
|
'util' => $this->util,
|
||
|
'logia' => $this->logia,
|
||
|
'terraza' => $this->terraza,
|
||
|
'superficie' => $this->superficie(),
|
||
|
'vendible' => $this->vendible(),
|
||
|
'descripcion' => $this->descripcion
|
||
|
]);
|
||
|
}
|
||
|
}
|