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)
{
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)) {
$time = Carbon::parse($time, config('app.timezone'));
$time = Carbon::parse($time, $this->container->get('settings')->app->timezone);
}
$this->time = $time;
}
@ -52,9 +52,9 @@ class Auth extends Model
if ($this->status == 0) {
return false;
}
$now = Carbon::now(config('app.timezone'));
$now = Carbon::now($this->container->get('settings')->app->timezone);
$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 true;

View File

@ -5,7 +5,7 @@ use Incoviba\Common\Alias\NewModel;
use Carbon\Carbon;
/**
*
*
* @author Aldarien
* @property Date fecha
* @property double valor
@ -14,20 +14,20 @@ use Carbon\Carbon;
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);
$fecha = Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
$uf = $this->container->get('uf')($fecha);
if ($uf != null) {
$this->valor = $uf->uf->value;
}
}
}

View File

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

View File

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

View File

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

View File

@ -25,7 +25,7 @@ class AvanceConstruccion extends Model
public function fecha(\DateTime $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');
}
@ -52,7 +52,7 @@ class AvanceConstruccion extends Model
public function uf()
{
if ($this->uf == 0) {
$uf = uf($this->fecha());
$uf = $this->container->get('uf')($this->fecha());
if ($uf->total > 0) {
$this->uf = $uf->uf->value;
$this->save();
@ -70,7 +70,7 @@ class AvanceConstruccion extends Model
public function fechaPago(\DateTime $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');
}

View File

@ -18,7 +18,7 @@ class EstadoProyectoAgente extends Model
}
public function fecha(\DateTime $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');
}

View File

@ -33,14 +33,14 @@ class Pagare extends Model
public function fecha(\DateTime $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');
}
public function fechaBanco(\DateTime $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');
}
@ -51,7 +51,7 @@ class Pagare extends Model
public function uf()
{
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) {
$this->uf = $uf->uf->value;
$this->save();

View File

@ -546,7 +546,7 @@ class Proyecto extends Model
if (isset($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)
->join('propiedad', ['propiedad.id', '=', 'venta.propiedad'])
->join('unidad', ['unidad.id', '=', 'propiedad.unidad_principal'])
@ -570,7 +570,7 @@ class Proyecto extends Model
if (isset($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)
->join('venta', ['cuota.pie', '=', 'venta.pie'])
->join('propiedad', ['propiedad.id', '=', 'venta.propiedad'])
@ -594,7 +594,7 @@ class Proyecto extends Model
if (isset($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)
->join('venta', ['cuota.pie', '=', 'venta.pie'])
->join('propiedad', ['propiedad.id', '=', 'venta.propiedad'])

View File

@ -23,14 +23,14 @@ class RenovacionPagare extends Model
public function fecha(\DateTime $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');
}
public function fechaBanco(\DateTime $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');
}
@ -41,7 +41,7 @@ class RenovacionPagare extends Model
public function uf()
{
if ($this->uf == 0) {
$uf = uf($this->fecha());
$uf = $this->container->get('uf')($this->fecha());
if ($uf->total > 0) {
$this->uf = $uf->uf->value;
$this->save();

View File

@ -69,7 +69,7 @@ class Cierre extends Model
public function fecha(\DateTime $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');
}
@ -234,7 +234,7 @@ class Cierre extends Model
if (isset($input->subrelacionado) and $input->subrelacionado) {
$this->relacionado = 2;
}
$fecha = Carbon::today(config('app.timezone'));
$fecha = Carbon::today($this->container->get('settings')->app->timezone);
$this->new($fecha);
$data = [
@ -350,7 +350,7 @@ class Cierre extends Model
return ($this->relacionado == 2) ? true : false;
}
public function periodo() {
$today = Carbon::today(config('app.timezone'));
$today = Carbon::today($this->container->get('settings')->app->timezone);
$dif = $today->diffInDays($this->fecha());
return $dif;
}
@ -360,6 +360,6 @@ class Cierre extends Model
if ($this->propietario()) {
$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)
{
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');
}

View File

@ -14,14 +14,14 @@ use Carbon\Carbon;
*
*/
class EstadoPago extends Model
{
{
public function tipo()
{
return $this->belongs_to(TipoEstadoPago::class, 'estado')->findOne();
}
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)
{
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)) {
$fecha = $fecha->format('Y-m-d');

View File

@ -19,7 +19,7 @@ class EstadoUnidadBloqueada extends Model
public function fecha(\DateTime $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');
}

View File

@ -22,6 +22,6 @@ class EstadoVenta extends Model
}
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()
{
if ($this->uf == 0) {
$uf = uf($this->fecha);
$uf = $this->container->get('uf')($this->fecha);
if (!$uf or $uf->total == 0) {
return 1;
}

View File

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

View File

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