Container

This commit is contained in:
2020-01-07 12:25:52 -03:00
parent 2300ca5641
commit 782e79dd30
19 changed files with 60 additions and 60 deletions

View File

@ -33,10 +33,10 @@ class Auth extends Model
public function time($time = null) public function time($time = null)
{ {
if ($time == null) { if ($time == null) {
return Carbon::parse($this->time, config('app.timezone')); return Carbon::parse($this->time, $this->container->get('settings')->app->timezone);
} }
if (!\is_a($time, \DateTime::class)) { if (!\is_a($time, \DateTime::class)) {
$time = Carbon::parse($time, config('app.timezone')); $time = Carbon::parse($time, $this->container->get('settings')->app->timezone);
} }
$this->time = $time; $this->time = $time;
} }
@ -52,9 +52,9 @@ class Auth extends Model
if ($this->status == 0) { if ($this->status == 0) {
return false; return false;
} }
$now = Carbon::now(config('app.timezone')); $now = Carbon::now($this->container->get('settings')->app->timezone);
$diff = $now->diffAsCarbonInterval($this->time, true); $diff = $now->diffAsCarbonInterval($this->time, true);
if ($diff->totalHours > config('app.login_hours')) { if ($diff->totalHours > $this->container->get('settings')->app->login->hours) {
return false; return false;
} }
return true; return true;

View File

@ -5,7 +5,7 @@ use Incoviba\Common\Alias\NewModel;
use Carbon\Carbon; use Carbon\Carbon;
/** /**
* *
* @author Aldarien * @author Aldarien
* @property Date fecha * @property Date fecha
* @property double valor * @property double valor
@ -14,20 +14,20 @@ use Carbon\Carbon;
class UF extends NewModel class UF extends NewModel
{ {
protected static $_table = 'ufs'; protected static $_table = 'ufs';
protected static $_id_column = 'fecha'; protected static $_id_column = 'fecha';
protected static $_timestamps = false; protected static $_timestamps = false;
//public $incrementing = false; //public $incrementing = false;
public function getValor() public function getValor()
{ {
$fecha = Carbon::parse($this->fecha, config('app.timezone')); $fecha = Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
$uf = uf($fecha); $uf = $this->container->get('uf')($fecha);
if ($uf != null) { if ($uf != null) {
$this->valor = $uf->uf->value; $this->valor = $uf->uf->value;
} }
} }
} }

View File

@ -6,7 +6,7 @@ use Incoviba\old\Proyecto\Proyecto as P;
use Carbon\Carbon; use Carbon\Carbon;
/** /**
* *
* @author Aldarien * @author Aldarien
* @property int $id * @property int $id
* @property Proyecto $proyecto_id * @property Proyecto $proyecto_id
@ -18,7 +18,7 @@ use Carbon\Carbon;
class Tema extends NewModel class Tema extends NewModel
{ {
protected static $_table = 'temas'; protected static $_table = 'temas';
public function proyecto() public function proyecto()
{ {
$proyecto = $this->belongsTo(Proyecto::class)->findOne(); $proyecto = $this->belongsTo(Proyecto::class)->findOne();
@ -29,11 +29,11 @@ class Tema extends NewModel
} }
public function inicio() public function inicio()
{ {
return Carbon::parse($this->inicio, config('app.timezone')); return Carbon::parse($this->inicio, $this->container->get('settings')->app->timezone);
} }
public function cierre() public function cierre()
{ {
return Carbon::parse($this->cierre, config('app.timezone')); return Carbon::parse($this->cierre, $this->container->get('settings')->app->timezone);
} }
public function texto() public function texto()
{ {
@ -46,7 +46,7 @@ class Tema extends NewModel
} }
} }
$text = implode('<br />', $text); $text = implode('<br />', $text);
preg_match_all('/\[\[.*\]\]/', $text, $matches); preg_match_all('/\[\[.*\]\]/', $text, $matches);
$search = []; $search = [];
$replace = []; $replace = [];
@ -56,7 +56,7 @@ class Tema extends NewModel
list($model, $where, $value) = explode(':', str_replace(['[',']'], ['', ''], $match)); list($model, $where, $value) = explode(':', str_replace(['[',']'], ['', ''], $match));
$class = '\\Incoviba\\old\\' . $model; $class = '\\Incoviba\\old\\' . $model;
$obj = model($class)->where($where, $value)->findOne(); $obj = model($class)->where($where, $value)->findOne();
$str = $value; $str = $value;
if ($obj->venta()) { if ($obj->venta()) {
$str = '<a href="'; $str = '<a href="';
@ -66,10 +66,10 @@ class Tema extends NewModel
$replace []= $str; $replace []= $str;
} }
} }
$text = str_replace($search, $replace, $text); $text = str_replace($search, $replace, $text);
return $text; return $text;
} }
} }
?> ?>

View File

@ -8,7 +8,7 @@ use Incoviba\nuevo\Proyecto\Proyecto;
use Incoviba\Common\Definition\hasEstado; use Incoviba\Common\Definition\hasEstado;
/** /**
* *
* @author Aldarien * @author Aldarien
* @property int $id * @property int $id
* @property Proyecto $proyecto_id * @property Proyecto $proyecto_id
@ -24,9 +24,9 @@ use Incoviba\Common\Definition\hasEstado;
class Cierre extends NewModel class Cierre extends NewModel
{ {
use hasEstado; use hasEstado;
protected static $_table = 'cierres'; protected static $_table = 'cierres';
public function proyecto() public function proyecto()
{ {
return $this->belongsTo(Proyecto::class, 'proyecto_id')->findOne(); return $this->belongsTo(Proyecto::class, 'proyecto_id')->findOne();
@ -45,15 +45,15 @@ class Cierre extends NewModel
} }
public function fecha() public function fecha()
{ {
return Carbon::parse($this->fecha, config('app.timezone')); return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
} }
public function pie($type = 'ufs') public function pie($type = 'ufs')
{ {
if ($type == 'ufs') { if ($type == 'ufs') {
return $this->pie; return $this->pie;
} }
$uf = uf($this->fecha()); $uf = $this->container->get('uf')($this->fecha());
return $this->pie * $uf->uf->value; return $this->pie * $uf->uf->value;
} }
} }
?> ?>

View File

@ -7,7 +7,7 @@ use Incoviba\nuevo\Inmobiliaria\Agente;
use Incoviba\Common\Definition\hasEstado; use Incoviba\Common\Definition\hasEstado;
/** /**
* *
* @author Aldarien * @author Aldarien
* @property int id * @property int id
* @property Propietario propietario_rut * @property Propietario propietario_rut
@ -19,15 +19,15 @@ use Incoviba\Common\Definition\hasEstado;
* @property boolean relacionado * @property boolean relacionado
* @property Agente agente_id * @property Agente agente_id
* @property DateTime created_at * @property DateTime created_at
* @property DateTime updated_at * @property DateTime updated_at
* *
*/ */
class Venta extends NewModel class Venta extends NewModel
{ {
use hasEstado; use hasEstado;
protected static $_table = 'ventas'; protected static $_table = 'ventas';
public function propietario() public function propietario()
{ {
return $this->belongs_to(Propietario::class, 'propietario_rut', 'rut')->findOne(); return $this->belongs_to(Propietario::class, 'propietario_rut', 'rut')->findOne();
@ -48,7 +48,7 @@ class Venta extends NewModel
} }
return null; return null;
} }
public function valor() public function valor()
{ {
return $this->valor_promesa * $this->uf; return $this->valor_promesa * $this->uf;
@ -70,9 +70,9 @@ class Venta extends NewModel
} }
public function fechaPromesa() public function fechaPromesa()
{ {
return Carbon::parse($this->fecha_promesa, config('app.timezone')); return Carbon::parse($this->fecha_promesa, $this->container->get('settings')->app->timezone);
} }
public function premios() public function premios()
{ {
$premios = $this->has_many(Premio::class, 'venta_id'); $premios = $this->has_many(Premio::class, 'venta_id');

View File

@ -25,7 +25,7 @@ class AvanceConstruccion extends Model
public function fecha(\DateTime $fecha = null) public function fecha(\DateTime $fecha = null)
{ {
if ($fecha == null) { if ($fecha == null) {
return Carbon::parse($this->fecha, config('app.timezone')); return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
} }
$this->fecha = $fecha->format('Y-m-d'); $this->fecha = $fecha->format('Y-m-d');
} }
@ -52,7 +52,7 @@ class AvanceConstruccion extends Model
public function uf() public function uf()
{ {
if ($this->uf == 0) { if ($this->uf == 0) {
$uf = uf($this->fecha()); $uf = $this->container->get('uf')($this->fecha());
if ($uf->total > 0) { if ($uf->total > 0) {
$this->uf = $uf->uf->value; $this->uf = $uf->uf->value;
$this->save(); $this->save();
@ -70,7 +70,7 @@ class AvanceConstruccion extends Model
public function fechaPago(\DateTime $fecha = null) public function fechaPago(\DateTime $fecha = null)
{ {
if ($fecha == null) { if ($fecha == null) {
return Carbon::parse($this->fecha_pagado, config('app.timezone')); return Carbon::parse($this->fecha_pagado, $this->container->get('settings')->app->timezone);
} }
$this->fecha_pagado = $fecha->format('Y-m-d'); $this->fecha_pagado = $fecha->format('Y-m-d');
} }

View File

@ -18,7 +18,7 @@ class EstadoProyectoAgente extends Model
} }
public function fecha(\DateTime $fecha = null) { public function fecha(\DateTime $fecha = null) {
if ($fecha == null) { if ($fecha == null) {
return Carbon::parse($this->fecha, config('app.timezone')); return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
} }
$this->fecha = $fecha->format('Y-m-d'); $this->fecha = $fecha->format('Y-m-d');
} }

View File

@ -33,14 +33,14 @@ class Pagare extends Model
public function fecha(\DateTime $fecha = null) public function fecha(\DateTime $fecha = null)
{ {
if ($fecha == null) { if ($fecha == null) {
return Carbon::parse($this->fecha, config('app.timezone')); return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
} }
$this->fecha = $fecha->format('Y-m-d'); $this->fecha = $fecha->format('Y-m-d');
} }
public function fechaBanco(\DateTime $fecha = null) public function fechaBanco(\DateTime $fecha = null)
{ {
if ($fecha == null) { if ($fecha == null) {
return Carbon::parse($this->fecha_banco, config('app.timezone')); return Carbon::parse($this->fecha_banco, $this->container->get('settings')->app->timezone);
} }
$this->fecha_banco = $fecha->format('Y-m-d'); $this->fecha_banco = $fecha->format('Y-m-d');
} }
@ -51,7 +51,7 @@ class Pagare extends Model
public function uf() public function uf()
{ {
if ($this->uf == 0 and $this->fecha != '0000-00-00') { if ($this->uf == 0 and $this->fecha != '0000-00-00') {
$uf = uf($this->fecha()); $uf = $this->container->get('uf')($this->fecha());
if ($uf->total > 0) { if ($uf->total > 0) {
$this->uf = $uf->uf->value; $this->uf = $uf->uf->value;
$this->save(); $this->save();

View File

@ -546,7 +546,7 @@ class Proyecto extends Model
if (isset($this->cuotas)) { if (isset($this->cuotas)) {
$cuotas = (array) $this->cuotas; $cuotas = (array) $this->cuotas;
} }
$f = Carbon::today(config('app.timezone')); $f = Carbon::today($this->container->get('settings')->app->timezone);
$cuotas['hoy'] = model(Venta::class) $cuotas['hoy'] = model(Venta::class)
->join('propiedad', ['propiedad.id', '=', 'venta.propiedad']) ->join('propiedad', ['propiedad.id', '=', 'venta.propiedad'])
->join('unidad', ['unidad.id', '=', 'propiedad.unidad_principal']) ->join('unidad', ['unidad.id', '=', 'propiedad.unidad_principal'])
@ -570,7 +570,7 @@ class Proyecto extends Model
if (isset($this->cuotas)) { if (isset($this->cuotas)) {
$cuotas = (array) $this->cuotas; $cuotas = (array) $this->cuotas;
} }
$f = Carbon::today(config('app.timezone')); $f = Carbon::today($this->container->get('settings')->app->timezone);
$cuotas['pendientes'] = model(Cuota::class) $cuotas['pendientes'] = model(Cuota::class)
->join('venta', ['cuota.pie', '=', 'venta.pie']) ->join('venta', ['cuota.pie', '=', 'venta.pie'])
->join('propiedad', ['propiedad.id', '=', 'venta.propiedad']) ->join('propiedad', ['propiedad.id', '=', 'venta.propiedad'])
@ -594,7 +594,7 @@ class Proyecto extends Model
if (isset($this->cuotas)) { if (isset($this->cuotas)) {
$cuotas = (array) $this->cuotas; $cuotas = (array) $this->cuotas;
} }
$f = Carbon::today(config('app.timezone')); $f = Carbon::today($this->container->get('settings')->app->timezone);
$cuotas['mes'] = model(Cuota::class) $cuotas['mes'] = model(Cuota::class)
->join('venta', ['cuota.pie', '=', 'venta.pie']) ->join('venta', ['cuota.pie', '=', 'venta.pie'])
->join('propiedad', ['propiedad.id', '=', 'venta.propiedad']) ->join('propiedad', ['propiedad.id', '=', 'venta.propiedad'])

View File

@ -23,14 +23,14 @@ class RenovacionPagare extends Model
public function fecha(\DateTime $fecha = null) public function fecha(\DateTime $fecha = null)
{ {
if ($fecha == null) { if ($fecha == null) {
return Carbon::parse($this->fecha, config('app.timezone')); return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
} }
$this->fecha = $fecha->format('Y-m-d'); $this->fecha = $fecha->format('Y-m-d');
} }
public function fechaBanco(\DateTime $fecha = null) public function fechaBanco(\DateTime $fecha = null)
{ {
if ($fecha == null) { if ($fecha == null) {
return Carbon::parse($this->fecha_banco, config('app.timezone')); return Carbon::parse($this->fecha_banco, $this->container->get('settings')->app->timezone);
} }
$this->fecha_banco = $fecha->format('Y-m-d'); $this->fecha_banco = $fecha->format('Y-m-d');
} }
@ -41,7 +41,7 @@ class RenovacionPagare extends Model
public function uf() public function uf()
{ {
if ($this->uf == 0) { if ($this->uf == 0) {
$uf = uf($this->fecha()); $uf = $this->container->get('uf')($this->fecha());
if ($uf->total > 0) { if ($uf->total > 0) {
$this->uf = $uf->uf->value; $this->uf = $uf->uf->value;
$this->save(); $this->save();

View File

@ -69,7 +69,7 @@ class Cierre extends Model
public function fecha(\DateTime $fecha = null) public function fecha(\DateTime $fecha = null)
{ {
if ($fecha == null) { if ($fecha == null) {
return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);//, config('app.timezone')); return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
} }
$this->fecha = $fecha->format('Y-m-d'); $this->fecha = $fecha->format('Y-m-d');
} }
@ -234,7 +234,7 @@ class Cierre extends Model
if (isset($input->subrelacionado) and $input->subrelacionado) { if (isset($input->subrelacionado) and $input->subrelacionado) {
$this->relacionado = 2; $this->relacionado = 2;
} }
$fecha = Carbon::today(config('app.timezone')); $fecha = Carbon::today($this->container->get('settings')->app->timezone);
$this->new($fecha); $this->new($fecha);
$data = [ $data = [
@ -350,7 +350,7 @@ class Cierre extends Model
return ($this->relacionado == 2) ? true : false; return ($this->relacionado == 2) ? true : false;
} }
public function periodo() { public function periodo() {
$today = Carbon::today(config('app.timezone')); $today = Carbon::today($this->container->get('settings')->app->timezone);
$dif = $today->diffInDays($this->fecha()); $dif = $today->diffInDays($this->fecha());
return $dif; return $dif;
} }
@ -360,6 +360,6 @@ class Cierre extends Model
if ($this->propietario()) { if ($this->propietario()) {
$arr['propietario'] = $this->propietario()->asArray(); $arr['propietario'] = $this->propietario()->asArray();
} }
return $arr; return $arr;
} }
} }

View File

@ -23,7 +23,7 @@ class EstadoCierre extends Model
public function fecha(\DateTime $fecha = null) public function fecha(\DateTime $fecha = null)
{ {
if ($fecha == null) { if ($fecha == null) {
return Carbon::parse($this->fecha, config('app.timezone')); return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
} }
$this->fecha = $fecha->format('Y-m-d'); $this->fecha = $fecha->format('Y-m-d');
} }

View File

@ -14,14 +14,14 @@ use Carbon\Carbon;
* *
*/ */
class EstadoPago extends Model class EstadoPago extends Model
{ {
public function tipo() public function tipo()
{ {
return $this->belongs_to(TipoEstadoPago::class, 'estado')->findOne(); return $this->belongs_to(TipoEstadoPago::class, 'estado')->findOne();
} }
public function fecha() public function fecha()
{ {
return Carbon::parse($this->fecha, config('app.timezone')); return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
} }
} }
?> ?>

View File

@ -19,7 +19,7 @@ class EstadoPrecio extends Model
public function fecha($fecha = null) public function fecha($fecha = null)
{ {
if ($fecha == null) { if ($fecha == null) {
return Carbon::parse($this->fecha, config('app.timezone')); return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
} }
if (is_a($fecha, \DateTime::class)) { if (is_a($fecha, \DateTime::class)) {
$fecha = $fecha->format('Y-m-d'); $fecha = $fecha->format('Y-m-d');

View File

@ -19,7 +19,7 @@ class EstadoUnidadBloqueada extends Model
public function fecha(\DateTime $fecha = null) public function fecha(\DateTime $fecha = null)
{ {
if ($fecha == null) { if ($fecha == null) {
return Carbon::parse($this->fecha, config('app.timezone')); return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
} }
$this->fecha = $fecha->format('Y-m-d'); $this->fecha = $fecha->format('Y-m-d');
} }

View File

@ -22,6 +22,6 @@ class EstadoVenta extends Model
} }
public function fecha() public function fecha()
{ {
return Carbon::parse($this->fecha, config('app.timezone')); return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
} }
} }

View File

@ -61,7 +61,7 @@ class Pago extends Model
public function uf() public function uf()
{ {
if ($this->uf == 0) { if ($this->uf == 0) {
$uf = uf($this->fecha); $uf = $this->container->get('uf')($this->fecha);
if (!$uf or $uf->total == 0) { if (!$uf or $uf->total == 0) {
return 1; return 1;
} }

View File

@ -196,7 +196,7 @@ class Pie extends Model
public function uf() public function uf()
{ {
if ($this->uf == 0) { if ($this->uf == 0) {
$uf = uf($this->fecha); $uf = $this->container->get('uf')($this->fecha);
if (!$uf) { if (!$uf) {
return 1; return 1;
} }

View File

@ -420,7 +420,7 @@ class Venta extends Model
{ {
if ($this->uf == null) { if ($this->uf == null) {
$f = $this->fecha(); $f = $this->fecha();
$uf = uf($f); $uf = $this->container->get('uf')($f);
if ($uf == null) { if ($uf == null) {
return 1; return 1;
} }