Nuevo models
This commit is contained in:
22
src/nuevo/Common/Banco.php
Normal file
22
src/nuevo/Common/Banco.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
*
|
||||
*/
|
||||
class Banco extends NewModel
|
||||
{
|
||||
protected static $_table = 'bancos';
|
||||
|
||||
//
|
||||
public function cuentas()
|
||||
{
|
||||
return $this->has_many(\Incoviba\nuevo\Inmobiliaria\Cuenta::class, 'banco_id')->findMany();
|
||||
}
|
||||
}
|
27
src/nuevo/Common/Comuna.php
Normal file
27
src/nuevo/Common/Comuna.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
* @property Provincia provincia_id
|
||||
*
|
||||
*/
|
||||
class Comuna extends NewModel
|
||||
{
|
||||
protected static $_table = 'comunas';
|
||||
|
||||
//
|
||||
public function provincia()
|
||||
{
|
||||
return $this->belongs_to(Provincia::class, 'provincia_id')->findOne();
|
||||
}
|
||||
public function direcciones()
|
||||
{
|
||||
return $this->has_many(Direccion::class, 'comuna_id')->findMany();
|
||||
}
|
||||
}
|
24
src/nuevo/Common/Direccion.php
Normal file
24
src/nuevo/Common/Direccion.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string calle
|
||||
* @property string numero
|
||||
* @property string extra
|
||||
* @property Comuna comuna_id
|
||||
*
|
||||
*/
|
||||
class Direccion extends NewModel
|
||||
{
|
||||
protected static $_table = 'direcciones';
|
||||
|
||||
public function comuna()
|
||||
{
|
||||
return $this->belongs_to(Comuna::class, 'comuna_id')->findOne();
|
||||
}
|
||||
}
|
33
src/nuevo/Common/M2.php
Normal file
33
src/nuevo/Common/M2.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property double util
|
||||
* @property double logia
|
||||
* @property double terraza
|
||||
* @property double cubierta
|
||||
* @property double terreno
|
||||
*
|
||||
*/
|
||||
class M2 extends NewModel
|
||||
{
|
||||
protected static $_table = 'm2s';
|
||||
|
||||
public function unidades()
|
||||
{
|
||||
return $this->has_many(\Incoviba\nuevo\Proyecto\UnidadProyecto::class, 'm2_id')->findMany();
|
||||
}
|
||||
public function vendibles()
|
||||
{
|
||||
return $this->util + $this->logia + $this->terraza / 2 + $this->cubierta / 3;
|
||||
}
|
||||
public function total()
|
||||
{
|
||||
return $this->util + $this->logia + $this->terraza + $this->cubierta;
|
||||
}
|
||||
}
|
27
src/nuevo/Common/Provincia.php
Normal file
27
src/nuevo/Common/Provincia.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
* @property Region region_id
|
||||
*
|
||||
*/
|
||||
class Provincia extends NewModel
|
||||
{
|
||||
protected static $_table = 'provincias';
|
||||
|
||||
//
|
||||
public function region()
|
||||
{
|
||||
return $this->belongs_to(Region::class, 'region_id')->findOne();
|
||||
}
|
||||
public function comunas()
|
||||
{
|
||||
return $this->has_many(Comuna::class, 'provincia_id')->findMany();
|
||||
}
|
||||
}
|
24
src/nuevo/Common/Region.php
Normal file
24
src/nuevo/Common/Region.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
* @property string nombre
|
||||
* @property string numeral
|
||||
* @property int orden
|
||||
*
|
||||
*/
|
||||
class Region extends NewModel
|
||||
{
|
||||
protected static $_table = 'regiones';
|
||||
|
||||
public function provincias()
|
||||
{
|
||||
return $this->has_many(Provincia::class, 'region_id')->findMany();
|
||||
}
|
||||
}
|
33
src/nuevo/Common/UF.php
Normal file
33
src/nuevo/Common/UF.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property Date fecha
|
||||
* @property double valor
|
||||
*
|
||||
*/
|
||||
class UF extends NewModel
|
||||
{
|
||||
protected static $_table = 'ufs';
|
||||
|
||||
protected static $_id_column = 'fecha';
|
||||
protected static $_timestamps = false;
|
||||
|
||||
//public $incrementing = false;
|
||||
|
||||
public function getValor()
|
||||
{
|
||||
$fecha = Carbon::parse($this->fecha, config('app.timezone'));
|
||||
$uf = uf($fecha);
|
||||
|
||||
if ($uf != null) {
|
||||
$this->valor = $uf->uf->value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user