Descripcion extensa de unidad
This commit is contained in:
@ -31,65 +31,13 @@ class Unidad extends Model {
|
|||||||
$this->proyecto_obj = $this->setRelationship(Proyecto::class, 'id', 'proyecto')->one();
|
$this->proyecto_obj = $this->setRelationship(Proyecto::class, 'id', 'proyecto')->one();
|
||||||
}
|
}
|
||||||
return $this->proyecto_obj;
|
return $this->proyecto_obj;
|
||||||
/*$proyecto = $this->belongs_to(Proyecto::class, 'proyecto')->findOne();
|
|
||||||
$proyecto->setContainer($this->container);
|
|
||||||
return $proyecto;*/
|
|
||||||
}
|
}
|
||||||
protected $propiedad;
|
protected $propiedad;
|
||||||
public function propiedad() {
|
public function propiedad() {
|
||||||
if ($this->propiedad === null) {
|
if ($this->propiedad === null) {
|
||||||
$this->propiedad = $this->setRelationship(PropiedadUnidad::class, 'unidad', 'id')->one();
|
$this->propiedad = $this->setRelationship(PropiedadUnidad::class, 'unidad', 'id')->one();
|
||||||
//$this->propiedad = $this->hasMany(PropiedadUnidad::class, 'unidad')->findOne();
|
|
||||||
}
|
}
|
||||||
return $this->propiedad;
|
return $this->propiedad;
|
||||||
|
|
||||||
/*if ($this->tipo()->descripcion == 'departamento') {
|
|
||||||
$propiedad = $this->has_one(Propiedad::class, 'unidad_principal');
|
|
||||||
if ($propiedad) {
|
|
||||||
return $propiedad->findOne();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if ($this->tipo()->descripcion == 'estacionamiento') {
|
|
||||||
// id | id; | ;id | ;id;
|
|
||||||
$propiedad = model(Propiedad::class)->whereLike('estacionamientos', $this->id)->findOne();
|
|
||||||
if ($propiedad) {
|
|
||||||
return $propiedad;
|
|
||||||
}
|
|
||||||
$propiedad = model(Propiedad::class)->whereLike('estacionamientos', '%;' . $this->id)->findOne();
|
|
||||||
if ($propiedad) {
|
|
||||||
return $propiedad;
|
|
||||||
}
|
|
||||||
$propiedad = model(Propiedad::class)->whereLike('estacionamientos', $this->id . ';%')->findOne();
|
|
||||||
if ($propiedad) {
|
|
||||||
return $propiedad;
|
|
||||||
}
|
|
||||||
$propiedad = model(Propiedad::class)->whereLike('estacionamientos', '%;' . $this->id . ';%')->findOne();
|
|
||||||
if ($propiedad) {
|
|
||||||
return $propiedad;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if ($this->tipo()->descripcion == 'bodega') {
|
|
||||||
// id | id; | ;id | ;id;
|
|
||||||
$propiedad = model(Propiedad::class)->whereLike('bodegas', $this->id)->findOne();
|
|
||||||
if ($propiedad) {
|
|
||||||
return $propiedad;
|
|
||||||
}
|
|
||||||
$propiedad = model(Propiedad::class)->whereLike('bodegas', '%;' . $this->id)->findOne();
|
|
||||||
if ($propiedad) {
|
|
||||||
return $propiedad;
|
|
||||||
}
|
|
||||||
$propiedad = model(Propiedad::class)->whereLike('bodegas', $this->id . ';%')->findOne();
|
|
||||||
if ($propiedad) {
|
|
||||||
return $propiedad;
|
|
||||||
}
|
|
||||||
$propiedad = model(Propiedad::class)->whereLike('bodegas', '%;' . $this->id . ';%')->findOne();
|
|
||||||
if ($propiedad) {
|
|
||||||
return $propiedad;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
protected $tipo_obj;
|
protected $tipo_obj;
|
||||||
public function tipo() {
|
public function tipo() {
|
||||||
@ -97,7 +45,6 @@ class Unidad extends Model {
|
|||||||
$this->tipo_obj = $this->setRelationship(TipoUnidad::class, 'id', 'tipo')->one();
|
$this->tipo_obj = $this->setRelationship(TipoUnidad::class, 'id', 'tipo')->one();
|
||||||
}
|
}
|
||||||
return $this->tipo_obj;
|
return $this->tipo_obj;
|
||||||
//return $this->belongs_to(TipoUnidad::class, 'tipo')->findOne();
|
|
||||||
}
|
}
|
||||||
private $venta = null;
|
private $venta = null;
|
||||||
public function venta() {
|
public function venta() {
|
||||||
@ -132,7 +79,6 @@ class Unidad extends Model {
|
|||||||
$this->precios = $this->setRelationship(Precio::class, 'unidad', 'id')->many();
|
$this->precios = $this->setRelationship(Precio::class, 'unidad', 'id')->many();
|
||||||
}
|
}
|
||||||
return $this->precios;
|
return $this->precios;
|
||||||
//return $this->hasMany(Precio::class, 'unidad')->findMany();
|
|
||||||
}
|
}
|
||||||
public function precio($fecha = null) {
|
public function precio($fecha = null) {
|
||||||
if ($fecha == null) {
|
if ($fecha == null) {
|
||||||
@ -188,7 +134,6 @@ class Unidad extends Model {
|
|||||||
$this->tipologia = $this->setRelationship(ProyectoTipoUnidad::class, 'id', 'pt')->one();
|
$this->tipologia = $this->setRelationship(ProyectoTipoUnidad::class, 'id', 'pt')->one();
|
||||||
}
|
}
|
||||||
return $this->tipologia;
|
return $this->tipologia;
|
||||||
//return $this->belongsTo(ProyectoTipoUnidad::class, 'pt')->findOne();
|
|
||||||
}
|
}
|
||||||
protected $is_vendida;
|
protected $is_vendida;
|
||||||
public function isVendida() {
|
public function isVendida() {
|
||||||
@ -251,4 +196,20 @@ class Unidad extends Model {
|
|||||||
}
|
}
|
||||||
return $this->linea;
|
return $this->linea;
|
||||||
}
|
}
|
||||||
|
protected $descripcion_full;
|
||||||
|
public function descripcion() {
|
||||||
|
if ($this->descripcion_full === null) {
|
||||||
|
$desc = [$this->descripcion];
|
||||||
|
$id = $this->id;
|
||||||
|
$unidades = array_filter($this->propiedad()->propiedad()->unidades(), function($item) use ($id) {
|
||||||
|
return ($item->unidad()->tipo()->descripcion == 'departamento' and $item->unidad()->id != $id);
|
||||||
|
});
|
||||||
|
foreach ($unidades as $unidad) {
|
||||||
|
$desc []= $unidad->unidad()->descripcion;
|
||||||
|
}
|
||||||
|
sort($desc);
|
||||||
|
$this->descripcion_full = implode(' - ', $desc);
|
||||||
|
}
|
||||||
|
return $this->descripcion_full;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user