Skip to content

Commit

Permalink
Merge pull request #675 from portabilis/portabilis-patch-2019-11-01
Browse files Browse the repository at this point in the history
[2.2] Portabilis patch 01/11/2019
  • Loading branch information
edersoares authored Nov 4, 2019
2 parents d01959b + 00a459b commit 23835d6
Show file tree
Hide file tree
Showing 33 changed files with 1,138 additions and 132 deletions.
11 changes: 11 additions & 0 deletions app/Extensions/Application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Extensions;

use EderSoares\Laravel\PlugAndPlay\Foundation\PlugAndPlayPackages;
use Illuminate\Foundation\Application as LaravelApplication;

class Application extends LaravelApplication
{
use PlugAndPlayPackages;
}
54 changes: 54 additions & 0 deletions app/Models/LegacyAddress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class LegacyAddress extends Model
{
/**
* @var string
*/
protected $table = 'public.logradouro';

/**
* @var string
*/
protected $primaryKey = 'idlog';

/**
* @var array
*/
protected $fillable = [
'idtlog',
'nome',
'idmun',
'geom',
'ident_oficial',
'idpes_rev',
'data_rev',
'origem_gravacao',
'idpes_cad',
'data_cad',
'operacao',
];

/**
* @var bool
*/
public $timestamps = false;

/**
* @inheritDoc
*/
protected static function boot()
{
parent::boot();

static::creating(function ($model) {
$model->origem_gravacao = 'M';
$model->data_cad = now();
$model->operacao = 'I';
});
}
}
69 changes: 69 additions & 0 deletions app/Models/LegacyCity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class LegacyCity extends Model
{
/**
* @var string
*/
protected $table = 'public.municipio';

/**
* @var string
*/
protected $primaryKey = 'idmun';

/**
* @var array
*/
protected $fillable = [
'idmun',
'nome',
'sigla_uf',
'area_km2',
'idmreg',
'idasmun',
'cod_ibge',
'geom',
'tipo',
'idmun_pai',
'idpes_rev',
'idpes_cad',
'data_rev',
'data_cad',
'origem_gravacao',
'operacao',
'nome_limpo',
];

/**
* @var bool
*/
public $timestamps = false;

/**
* @inheritDoc
*/
protected static function boot()
{
parent::boot();

static::creating(function ($model) {
$model->origem_gravacao = 'M';
$model->data_cad = now();
$model->operacao = 'I';
});
}

/**
* @return HasMany
*/
public function districts()
{
return $this->hasMany(LegacyDistrict::class, 'idmun', 'idmun');
}
}
57 changes: 57 additions & 0 deletions app/Models/LegacyDistrict.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class LegacyDistrict extends Model
{
/**
* @var string
*/
protected $table = 'public.distrito';

/**
* @var string
*/
protected $primaryKey = 'iddis';

/**
* @var array
*/
protected $fillable = [
'idmun',
'geom',
'iddis',
'nome',
'cod_ibge',
'idpes_rev',
'data_rev',
'origem_gravacao',
'idpes_cad',
'data_cad',
'operacao',
];

/**
* @var bool
*/
public $timestamps = false;

/**
* @inheritDoc
*/
protected static function boot()
{
parent::boot();

static::creating(function ($model) {
$district = LegacyDistrict::query()->whereKey($model->idmun)->first();

$model->origem_gravacao = 'M';
$model->data_cad = now();
$model->operacao = 'I';
$model->iddis = $district->getKey();
});
}
}
65 changes: 65 additions & 0 deletions app/Models/LegacyExternalAddress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class LegacyExternalAddress extends Model
{
/**
* @var string
*/
protected $table = 'cadastro.endereco_externo';

/**
* @var string
*/
protected $primaryKey = 'idpes';

/**
* @var array
*/
protected $fillable = [
'idpes',
'tipo',
'idtlog',
'logradouro',
'numero',
'letra',
'complemento',
'bairro',
'cep',
'cidade',
'sigla_uf',
'reside_desde',
'idpes_rev',
'data_rev',
'origem_gravacao',
'idpes_cad',
'data_cad',
'operacao',
'bloco',
'andar',
'apartamento',
'zona_localizacao',
];

/**
* @var bool
*/
public $timestamps = false;

/**
* @inheritDoc
*/
protected static function boot()
{
parent::boot();

static::creating(function ($model) {
$model->data_cad = now();
$model->origem_gravacao = 'M';
$model->operacao = 'I';
});
}
}
89 changes: 88 additions & 1 deletion app/Models/LegacyIndividual.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;

Expand All @@ -28,11 +29,97 @@ class LegacyIndividual extends EloquentBaseModel implements Transformable
* @var array
*/
protected $fillable = [
'idpes', 'data_cad', 'operacao', 'origem_gravacao',
'idpes',
'data_nasc',
'sexo',
'idpes_mae',
'idpes_pai',
'idpes_responsavel',
'idesco',
'ideciv',
'idpes_con',
'data_uniao',
'data_obito',
'nacionalidade',
'idpais_estrangeiro',
'data_chegada_brasil',
'idmun_nascimento',
'ultima_empresa',
'idocup',
'nome_mae',
'nome_pai',
'nome_conjuge',
'nome_responsavel',
'justificativa_provisorio',
'idpes_rev',
'data_rev',
'origem_gravacao',
'idpes_cad',
'data_cad',
'operacao',
'ref_cod_sistema',
'cpf',
'ref_cod_religiao',
'nis_pis_pasep',
'sus',
'ocupacao',
'empresa',
'pessoa_contato',
'renda_mensal',
'data_admissao',
'ddd_telefone_empresa',
'telefone_empresa',
'falecido',
'ativo',
'ref_usuario_exc',
'data_exclusao',
'zona_localizacao_censo',
'tipo_trabalho',
'local_trabalho',
'horario_inicial_trabalho',
'horario_final_trabalho',
'nome_social',
'pais_residencia',
'localizacao_diferenciada',
];

/**
* @var bool
*/
public $timestamps = false;

/**
* @inheritDoc
*/
protected static function boot()
{
parent::boot();

static::creating(function ($model) {
$model->data_cad = now();
$model->origem_gravacao = 'M';
$model->operacao = 'I';
});
}

/**
* @return BelongsTo
*/
public function person()
{
return $this->belongsTo(LegacyPerson::class, 'idpes', 'idpes');
}

/**
* @param string $cpf
*
* @return $this
*/
public static function findByCpf($cpf)
{
$cpf = preg_replace('/[^0-9]/', '', $cpf);
$cpf = intval($cpf);

return static::query()->where('cpf', $cpf)->first();
}
}
30 changes: 30 additions & 0 deletions app/Models/LegacyMaritalStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class LegacyMaritalStatus extends Model
{
/**
* @var string
*/
protected $table = 'cadastro.estado_civil';

/**
* @var string
*/
protected $primaryKey = 'ideciv';

/**
* @var array
*/
protected $fillable = [
'descricao',
];

/**
* @var bool
*/
public $timestamps = false;
}
Loading

0 comments on commit 23835d6

Please sign in to comment.