Commit da04908354e53e3d886b860351dbab2201d6e1d4

Authored by Eder Soares
2 parents d01959b6 9acd7287
Exists in master

Merge branch 'master' into community-patch-2019-11-08

Showing 46 changed files with 1690 additions and 247 deletions   Show diff stats
.env.example
... ... @@ -57,8 +57,7 @@ GOOGLE_TAG_MANAGER=
57 57  
58 58 FILESYSTEM_DRIVER=local
59 59  
60   -AWS_KEY=
61   -AWS_SECRET=
  60 +AWS_ACCESS_KEY_ID=
  61 +AWS_SECRET_ACCESS_KEY=
62 62 AWS_DEFAULT_REGION=
63 63 AWS_BUCKET=
64   -AWS_URL=
... ...
app/Extensions/Application.php 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +<?php
  2 +
  3 +namespace App\Extensions;
  4 +
  5 +use EderSoares\Laravel\PlugAndPlay\Foundation\PlugAndPlayPackages;
  6 +use Illuminate\Foundation\Application as LaravelApplication;
  7 +
  8 +class Application extends LaravelApplication
  9 +{
  10 + use PlugAndPlayPackages;
  11 +}
... ...
app/Http/Controllers/BackupController.php 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers;
  4 +
  5 +use App\Services\BackupUrlPresigner;
  6 +use Illuminate\Http\Request;
  7 +use Redirect;
  8 +
  9 +class BackupController extends Controller
  10 +{
  11 + public function download(Request $request, BackupUrlPresigner $backupUrlPresigner)
  12 + {
  13 + $presignedUrl = $backupUrlPresigner->getPresignedUrl($request->url);
  14 +
  15 + return Redirect::away($presignedUrl);
  16 + }
  17 +}
... ...
app/Http/Kernel.php
... ... @@ -21,6 +21,7 @@ class Kernel extends HttpKernel
21 21 \App\Http\Middleware\TrustProxies::class,
22 22 \App\Http\Middleware\ChangeAppName::class,
23 23 \App\Http\Middleware\ConnectTenantDatabase::class,
  24 + \App\Http\Middleware\LoadSettings::class,
24 25 ];
25 26  
26 27 /**
... ... @@ -38,12 +39,12 @@ class Kernel extends HttpKernel
38 39 // \App\Http\Middleware\VerifyCsrfToken::class,
39 40 \Illuminate\Routing\Middleware\SubstituteBindings::class,
40 41 \App\Http\Middleware\SetLayoutVariables::class,
41   - \App\Http\Middleware\LoadSettings::class,
42 42 ],
43 43  
44 44 'api' => [
45 45 'throttle:60,1',
46 46 'bindings',
  47 + \Barryvdh\Cors\HandleCors::class
47 48 ],
48 49 ];
49 50  
... ...
app/Models/LegacyAddress.php 0 → 100644
... ... @@ -0,0 +1,54 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +
  7 +class LegacyAddress extends Model
  8 +{
  9 + /**
  10 + * @var string
  11 + */
  12 + protected $table = 'public.logradouro';
  13 +
  14 + /**
  15 + * @var string
  16 + */
  17 + protected $primaryKey = 'idlog';
  18 +
  19 + /**
  20 + * @var array
  21 + */
  22 + protected $fillable = [
  23 + 'idtlog',
  24 + 'nome',
  25 + 'idmun',
  26 + 'geom',
  27 + 'ident_oficial',
  28 + 'idpes_rev',
  29 + 'data_rev',
  30 + 'origem_gravacao',
  31 + 'idpes_cad',
  32 + 'data_cad',
  33 + 'operacao',
  34 + ];
  35 +
  36 + /**
  37 + * @var bool
  38 + */
  39 + public $timestamps = false;
  40 +
  41 + /**
  42 + * @inheritDoc
  43 + */
  44 + protected static function boot()
  45 + {
  46 + parent::boot();
  47 +
  48 + static::creating(function ($model) {
  49 + $model->origem_gravacao = 'M';
  50 + $model->data_cad = now();
  51 + $model->operacao = 'I';
  52 + });
  53 + }
  54 +}
... ...
app/Models/LegacyCity.php 0 → 100644
... ... @@ -0,0 +1,69 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +use Illuminate\Database\Eloquent\Relations\HasMany;
  7 +
  8 +class LegacyCity extends Model
  9 +{
  10 + /**
  11 + * @var string
  12 + */
  13 + protected $table = 'public.municipio';
  14 +
  15 + /**
  16 + * @var string
  17 + */
  18 + protected $primaryKey = 'idmun';
  19 +
  20 + /**
  21 + * @var array
  22 + */
  23 + protected $fillable = [
  24 + 'idmun',
  25 + 'nome',
  26 + 'sigla_uf',
  27 + 'area_km2',
  28 + 'idmreg',
  29 + 'idasmun',
  30 + 'cod_ibge',
  31 + 'geom',
  32 + 'tipo',
  33 + 'idmun_pai',
  34 + 'idpes_rev',
  35 + 'idpes_cad',
  36 + 'data_rev',
  37 + 'data_cad',
  38 + 'origem_gravacao',
  39 + 'operacao',
  40 + 'nome_limpo',
  41 + ];
  42 +
  43 + /**
  44 + * @var bool
  45 + */
  46 + public $timestamps = false;
  47 +
  48 + /**
  49 + * @inheritDoc
  50 + */
  51 + protected static function boot()
  52 + {
  53 + parent::boot();
  54 +
  55 + static::creating(function ($model) {
  56 + $model->origem_gravacao = 'M';
  57 + $model->data_cad = now();
  58 + $model->operacao = 'I';
  59 + });
  60 + }
  61 +
  62 + /**
  63 + * @return HasMany
  64 + */
  65 + public function districts()
  66 + {
  67 + return $this->hasMany(LegacyDistrict::class, 'idmun', 'idmun');
  68 + }
  69 +}
... ...
app/Models/LegacyDistrict.php 0 → 100644
... ... @@ -0,0 +1,57 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +
  7 +class LegacyDistrict extends Model
  8 +{
  9 + /**
  10 + * @var string
  11 + */
  12 + protected $table = 'public.distrito';
  13 +
  14 + /**
  15 + * @var string
  16 + */
  17 + protected $primaryKey = 'iddis';
  18 +
  19 + /**
  20 + * @var array
  21 + */
  22 + protected $fillable = [
  23 + 'idmun',
  24 + 'geom',
  25 + 'iddis',
  26 + 'nome',
  27 + 'cod_ibge',
  28 + 'idpes_rev',
  29 + 'data_rev',
  30 + 'origem_gravacao',
  31 + 'idpes_cad',
  32 + 'data_cad',
  33 + 'operacao',
  34 + ];
  35 +
  36 + /**
  37 + * @var bool
  38 + */
  39 + public $timestamps = false;
  40 +
  41 + /**
  42 + * @inheritDoc
  43 + */
  44 + protected static function boot()
  45 + {
  46 + parent::boot();
  47 +
  48 + static::creating(function ($model) {
  49 + $district = LegacyDistrict::query()->whereKey($model->idmun)->first();
  50 +
  51 + $model->origem_gravacao = 'M';
  52 + $model->data_cad = now();
  53 + $model->operacao = 'I';
  54 + $model->iddis = $district->getKey();
  55 + });
  56 + }
  57 +}
... ...
app/Models/LegacyExternalAddress.php 0 → 100644
... ... @@ -0,0 +1,65 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +
  7 +class LegacyExternalAddress extends Model
  8 +{
  9 + /**
  10 + * @var string
  11 + */
  12 + protected $table = 'cadastro.endereco_externo';
  13 +
  14 + /**
  15 + * @var string
  16 + */
  17 + protected $primaryKey = 'idpes';
  18 +
  19 + /**
  20 + * @var array
  21 + */
  22 + protected $fillable = [
  23 + 'idpes',
  24 + 'tipo',
  25 + 'idtlog',
  26 + 'logradouro',
  27 + 'numero',
  28 + 'letra',
  29 + 'complemento',
  30 + 'bairro',
  31 + 'cep',
  32 + 'cidade',
  33 + 'sigla_uf',
  34 + 'reside_desde',
  35 + 'idpes_rev',
  36 + 'data_rev',
  37 + 'origem_gravacao',
  38 + 'idpes_cad',
  39 + 'data_cad',
  40 + 'operacao',
  41 + 'bloco',
  42 + 'andar',
  43 + 'apartamento',
  44 + 'zona_localizacao',
  45 + ];
  46 +
  47 + /**
  48 + * @var bool
  49 + */
  50 + public $timestamps = false;
  51 +
  52 + /**
  53 + * @inheritDoc
  54 + */
  55 + protected static function boot()
  56 + {
  57 + parent::boot();
  58 +
  59 + static::creating(function ($model) {
  60 + $model->data_cad = now();
  61 + $model->origem_gravacao = 'M';
  62 + $model->operacao = 'I';
  63 + });
  64 + }
  65 +}
... ...
app/Models/LegacyGrade.php 0 → 100644
... ... @@ -0,0 +1,71 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +use Illuminate\Database\Eloquent\Relations\BelongsTo;
  7 +use Illuminate\Database\Eloquent\Relations\BelongsToMany;
  8 +
  9 +class LegacyGrade extends Model
  10 +{
  11 + /**
  12 + * @var string
  13 + */
  14 + protected $table = 'pmieducar.serie';
  15 +
  16 + /**
  17 + * @var string
  18 + */
  19 + protected $primaryKey = 'cod_serie';
  20 +
  21 + /**
  22 + * @var array
  23 + */
  24 + protected $fillable = [
  25 + 'nm_serie', 'ref_usuario_cad', 'ref_cod_curso', 'etapa_curso', 'carga_horaria', 'data_cadastro',
  26 + ];
  27 +
  28 + /**
  29 + * @var bool
  30 + */
  31 + public $timestamps = false;
  32 +
  33 + /**
  34 + * @return string
  35 + */
  36 + public function getNameAttribute()
  37 + {
  38 + return $this->nm_serie;
  39 + }
  40 +
  41 + /**
  42 + * @return int
  43 + */
  44 + public function getCourseIdAttribute()
  45 + {
  46 + return $this->ref_cod_curso;
  47 + }
  48 +
  49 + /**
  50 + * @return BelongsToMany
  51 + */
  52 + public function evaluationRules()
  53 + {
  54 + return $this->belongsToMany(
  55 + LegacyEvaluationRule::class,
  56 + 'modules.regra_avaliacao_serie_ano',
  57 + 'serie_id',
  58 + 'regra_avaliacao_id'
  59 + )->withPivot('ano_letivo', 'regra_avaliacao_diferenciada_id');
  60 + }
  61 +
  62 + /**
  63 + * Relacionamento com o curso.
  64 + *
  65 + * @return BelongsTo
  66 + */
  67 + public function course()
  68 + {
  69 + return $this->belongsTo(LegacyCourse::class, 'ref_cod_curso');
  70 + }
  71 +}
... ...
app/Models/LegacyIndividual.php
... ... @@ -2,6 +2,7 @@
2 2  
3 3 namespace App\Models;
4 4  
  5 +use Illuminate\Database\Eloquent\Relations\BelongsTo;
5 6 use Prettus\Repository\Contracts\Transformable;
6 7 use Prettus\Repository\Traits\TransformableTrait;
7 8  
... ... @@ -28,11 +29,97 @@ class LegacyIndividual extends EloquentBaseModel implements Transformable
28 29 * @var array
29 30 */
30 31 protected $fillable = [
31   - 'idpes', 'data_cad', 'operacao', 'origem_gravacao',
  32 + 'idpes',
  33 + 'data_nasc',
  34 + 'sexo',
  35 + 'idpes_mae',
  36 + 'idpes_pai',
  37 + 'idpes_responsavel',
  38 + 'idesco',
  39 + 'ideciv',
  40 + 'idpes_con',
  41 + 'data_uniao',
  42 + 'data_obito',
  43 + 'nacionalidade',
  44 + 'idpais_estrangeiro',
  45 + 'data_chegada_brasil',
  46 + 'idmun_nascimento',
  47 + 'ultima_empresa',
  48 + 'idocup',
  49 + 'nome_mae',
  50 + 'nome_pai',
  51 + 'nome_conjuge',
  52 + 'nome_responsavel',
  53 + 'justificativa_provisorio',
  54 + 'idpes_rev',
  55 + 'data_rev',
  56 + 'origem_gravacao',
  57 + 'idpes_cad',
  58 + 'data_cad',
  59 + 'operacao',
  60 + 'ref_cod_sistema',
  61 + 'cpf',
  62 + 'ref_cod_religiao',
  63 + 'nis_pis_pasep',
  64 + 'sus',
  65 + 'ocupacao',
  66 + 'empresa',
  67 + 'pessoa_contato',
  68 + 'renda_mensal',
  69 + 'data_admissao',
  70 + 'ddd_telefone_empresa',
  71 + 'telefone_empresa',
  72 + 'falecido',
  73 + 'ativo',
  74 + 'ref_usuario_exc',
  75 + 'data_exclusao',
  76 + 'zona_localizacao_censo',
  77 + 'tipo_trabalho',
  78 + 'local_trabalho',
  79 + 'horario_inicial_trabalho',
  80 + 'horario_final_trabalho',
  81 + 'nome_social',
  82 + 'pais_residencia',
  83 + 'localizacao_diferenciada',
32 84 ];
33 85  
34 86 /**
35 87 * @var bool
36 88 */
37 89 public $timestamps = false;
  90 +
  91 + /**
  92 + * @inheritDoc
  93 + */
  94 + protected static function boot()
  95 + {
  96 + parent::boot();
  97 +
  98 + static::creating(function ($model) {
  99 + $model->data_cad = now();
  100 + $model->origem_gravacao = 'M';
  101 + $model->operacao = 'I';
  102 + });
  103 + }
  104 +
  105 + /**
  106 + * @return BelongsTo
  107 + */
  108 + public function person()
  109 + {
  110 + return $this->belongsTo(LegacyPerson::class, 'idpes', 'idpes');
  111 + }
  112 +
  113 + /**
  114 + * @param string $cpf
  115 + *
  116 + * @return $this
  117 + */
  118 + public static function findByCpf($cpf)
  119 + {
  120 + $cpf = preg_replace('/[^0-9]/', '', $cpf);
  121 + $cpf = intval($cpf);
  122 +
  123 + return static::query()->where('cpf', $cpf)->first();
  124 + }
38 125 }
... ...
app/Models/LegacyLevel.php
... ... @@ -2,66 +2,12 @@
2 2  
3 3 namespace App\Models;
4 4  
5   -use Illuminate\Database\Eloquent\Model;
6   -use Illuminate\Database\Eloquent\Relations\BelongsTo;
7   -
8   -class LegacyLevel extends Model
  5 +/**
  6 + * @deprecated
  7 + *
  8 + * @see LegacyGrade
  9 + */
  10 +class LegacyLevel extends LegacyGrade
9 11 {
10   - /**
11   - * @var string
12   - */
13   - protected $table = 'pmieducar.serie';
14   -
15   - /**
16   - * @var string
17   - */
18   - protected $primaryKey = 'cod_serie';
19   -
20   - /**
21   - * @var array
22   - */
23   - protected $fillable = [
24   - 'nm_serie', 'ref_usuario_cad', 'ref_cod_curso', 'etapa_curso', 'carga_horaria', 'data_cadastro',
25   - ];
26   -
27   - /**
28   - * @var bool
29   - */
30   - public $timestamps = false;
31   -
32   - /**
33   - * @return string
34   - */
35   - public function getNameAttribute()
36   - {
37   - return $this->nm_serie;
38   - }
39   -
40   - public function getCourseIdAttribute()
41   - {
42   - return $this->ref_cod_curso;
43   - }
44   -
45   - /**
46   - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
47   - */
48   - public function evaluationRules()
49   - {
50   - return $this->belongsToMany(
51   - LegacyEvaluationRule::class,
52   - 'modules.regra_avaliacao_serie_ano',
53   - 'serie_id',
54   - 'regra_avaliacao_id'
55   - )->withPivot('ano_letivo', 'regra_avaliacao_diferenciada_id');
56   - }
57 12  
58   - /**
59   - * Relacionamento com o curso.
60   - *
61   - * @return BelongsTo
62   - */
63   - public function course()
64   - {
65   - return $this->belongsTo(LegacyCourse::class, 'ref_cod_curso');
66   - }
67 13 }
... ...
app/Models/LegacyMaritalStatus.php 0 → 100644
... ... @@ -0,0 +1,30 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +
  7 +class LegacyMaritalStatus extends Model
  8 +{
  9 + /**
  10 + * @var string
  11 + */
  12 + protected $table = 'cadastro.estado_civil';
  13 +
  14 + /**
  15 + * @var string
  16 + */
  17 + protected $primaryKey = 'ideciv';
  18 +
  19 + /**
  20 + * @var array
  21 + */
  22 + protected $fillable = [
  23 + 'descricao',
  24 + ];
  25 +
  26 + /**
  27 + * @var bool
  28 + */
  29 + public $timestamps = false;
  30 +}
... ...
app/Models/LegacyNeighborhood.php 0 → 100644
... ... @@ -0,0 +1,56 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +
  7 +class LegacyNeighborhood extends Model
  8 +{
  9 + /**
  10 + * @var string
  11 + */
  12 + protected $table = 'public.bairro';
  13 +
  14 + /**
  15 + * @var string
  16 + */
  17 + protected $primaryKey = 'idbai';
  18 +
  19 + /**
  20 + * @var array
  21 + */
  22 + protected $fillable = [
  23 + 'idmun',
  24 + 'geom',
  25 + 'idbai',
  26 + 'nome',
  27 + 'idpes_rev',
  28 + 'data_rev',
  29 + 'origem_gravacao',
  30 + 'idpes_cad',
  31 + 'data_cad',
  32 + 'operacao',
  33 + 'zona_localizacao',
  34 + 'iddis',
  35 + 'idsetorbai',
  36 + ];
  37 +
  38 + /**
  39 + * @var bool
  40 + */
  41 + public $timestamps = false;
  42 +
  43 + /**
  44 + * @inheritDoc
  45 + */
  46 + protected static function boot()
  47 + {
  48 + parent::boot();
  49 +
  50 + static::creating(function ($model) {
  51 + $model->origem_gravacao = 'M';
  52 + $model->data_cad = now();
  53 + $model->operacao = 'I';
  54 + });
  55 + }
  56 +}
... ...
app/Models/LegacyPeriod.php 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +
  7 +class LegacyPeriod extends Model
  8 +{
  9 + /**
  10 + * @var string
  11 + */
  12 + protected $table = 'pmieducar.turma_turno';
  13 +
  14 + /**
  15 + * @var array
  16 + */
  17 + protected $fillable = [
  18 + 'nome', 'ativo',
  19 + ];
  20 +
  21 + /**
  22 + * @var bool
  23 + */
  24 + public $timestamps = false;
  25 +
  26 + /**
  27 + * @return string
  28 + */
  29 + public function getNameAttribute()
  30 + {
  31 + return $this->nome;
  32 + }
  33 +}
... ...
app/Models/LegacyPerson.php
... ... @@ -35,6 +35,21 @@ class LegacyPerson extends EloquentBaseModel implements Transformable
35 35 public $timestamps = false;
36 36  
37 37 /**
  38 + * @inheritDoc
  39 + */
  40 + protected static function boot()
  41 + {
  42 + parent::boot();
  43 +
  44 + static::creating(function ($model) {
  45 + $model->data_cad = now();
  46 + $model->situacao = 'I';
  47 + $model->origem_gravacao = 'M';
  48 + $model->operacao = 'I';
  49 + });
  50 + }
  51 +
  52 + /**
38 53 * @return string
39 54 */
40 55 public function getNameAttribute()
... ...
app/Models/LegacyPersonAddress.php 0 → 100644
... ... @@ -0,0 +1,62 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +
  7 +class LegacyPersonAddress extends Model
  8 +{
  9 + /**
  10 + * @var string
  11 + */
  12 + protected $table = 'cadastro.endereco_pessoa';
  13 +
  14 + /**
  15 + * @var string
  16 + */
  17 + protected $primaryKey = 'idpes';
  18 +
  19 + /**
  20 + * @var array
  21 + */
  22 + protected $fillable = [
  23 + 'idpes',
  24 + 'tipo',
  25 + 'cep',
  26 + 'idlog',
  27 + 'numero',
  28 + 'letra',
  29 + 'complemento',
  30 + 'reside_desde',
  31 + 'idbai',
  32 + 'idpes_rev',
  33 + 'data_rev',
  34 + 'origem_gravacao',
  35 + 'idpes_cad',
  36 + 'data_cad',
  37 + 'operacao',
  38 + 'bloco',
  39 + 'andar',
  40 + 'apartamento',
  41 + 'observacoes',
  42 + ];
  43 +
  44 + /**
  45 + * @var bool
  46 + */
  47 + public $timestamps = false;
  48 +
  49 + /**
  50 + * @inheritDoc
  51 + */
  52 + protected static function boot()
  53 + {
  54 + parent::boot();
  55 +
  56 + static::creating(function ($model) {
  57 + $model->origem_gravacao = 'M';
  58 + $model->data_cad = now();
  59 + $model->operacao = 'I';
  60 + });
  61 + }
  62 +}
... ...
app/Models/LegacyPhone.php 0 → 100644
... ... @@ -0,0 +1,53 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +
  7 +class LegacyPhone extends Model
  8 +{
  9 + /**
  10 + * @var string
  11 + */
  12 + protected $table = 'cadastro.fone_pessoa';
  13 +
  14 + /**
  15 + * @var string
  16 + */
  17 + protected $primaryKey = 'idpes';
  18 +
  19 + /**
  20 + * @var array
  21 + */
  22 + protected $fillable = [
  23 + 'idpes',
  24 + 'tipo',
  25 + 'ddd',
  26 + 'fone',
  27 + 'idpes_rev',
  28 + 'data_rev',
  29 + 'origem_gravacao',
  30 + 'idpes_cad',
  31 + 'data_cad',
  32 + 'operacao',
  33 + ];
  34 +
  35 + /**
  36 + * @var bool
  37 + */
  38 + public $timestamps = false;
  39 +
  40 + /**
  41 + * @inheritDoc
  42 + */
  43 + protected static function boot()
  44 + {
  45 + parent::boot();
  46 +
  47 + static::creating(function ($model) {
  48 + $model->origem_gravacao = 'M';
  49 + $model->data_cad = now();
  50 + $model->operacao = 'I';
  51 + });
  52 + }
  53 +}
... ...
app/Models/LegacyPostalCodeAddress.php 0 → 100644
... ... @@ -0,0 +1,53 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +
  7 +class LegacyPostalCodeAddress extends Model
  8 +{
  9 + /**
  10 + * @var string
  11 + */
  12 + protected $table = 'urbano.cep_logradouro';
  13 +
  14 + /**
  15 + * @var string
  16 + */
  17 + protected $primaryKey = 'idlog';
  18 +
  19 + /**
  20 + * @var array
  21 + */
  22 + protected $fillable = [
  23 + 'cep',
  24 + 'idlog',
  25 + 'nroini',
  26 + 'nrofin',
  27 + 'idpes_rev',
  28 + 'data_rev',
  29 + 'origem_gravacao',
  30 + 'idpes_cad',
  31 + 'data_cad',
  32 + 'operacao',
  33 + ];
  34 +
  35 + /**
  36 + * @var bool
  37 + */
  38 + public $timestamps = false;
  39 +
  40 + /**
  41 + * @inheritDoc
  42 + */
  43 + protected static function boot()
  44 + {
  45 + parent::boot();
  46 +
  47 + static::creating(function ($model) {
  48 + $model->origem_gravacao = 'M';
  49 + $model->data_cad = now();
  50 + $model->operacao = 'I';
  51 + });
  52 + }
  53 +}
... ...
app/Models/LegacyPostalCodeAddressNeighborhood.php 0 → 100644
... ... @@ -0,0 +1,52 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +
  7 +class LegacyPostalCodeAddressNeighborhood extends Model
  8 +{
  9 + /**
  10 + * @var string
  11 + */
  12 + protected $table = 'urbano.cep_logradouro_bairro';
  13 +
  14 + /**
  15 + * @var string
  16 + */
  17 + protected $primaryKey = 'idlog';
  18 +
  19 + /**
  20 + * @var array
  21 + */
  22 + protected $fillable = [
  23 + 'idlog',
  24 + 'cep',
  25 + 'idbai',
  26 + 'idpes_rev',
  27 + 'data_rev',
  28 + 'origem_gravacao',
  29 + 'idpes_cad',
  30 + 'data_cad',
  31 + 'operacao',
  32 + ];
  33 +
  34 + /**
  35 + * @var bool
  36 + */
  37 + public $timestamps = false;
  38 +
  39 + /**
  40 + * @inheritDoc
  41 + */
  42 + protected static function boot()
  43 + {
  44 + parent::boot();
  45 +
  46 + static::creating(function ($model) {
  47 + $model->origem_gravacao = 'M';
  48 + $model->data_cad = now();
  49 + $model->operacao = 'I';
  50 + });
  51 + }
  52 +}
... ...
app/Models/LegacySchool.php
... ... @@ -5,6 +5,7 @@ namespace App\Models;
5 5 use Illuminate\Database\Eloquent\Model;
6 6 use Illuminate\Database\Eloquent\Relations\BelongsTo;
7 7 use Illuminate\Database\Eloquent\Relations\BelongsToMany;
  8 +use Illuminate\Database\Eloquent\Relations\HasMany;
8 9 use Illuminate\Support\Facades\DB;
9 10  
10 11 /**
... ... @@ -92,4 +93,25 @@ class LegacySchool extends Model
92 93 {
93 94 return DB::selectOne('SELECT relatorio.get_nome_escola(:escola) AS nome', ['escola' => $this->id])->nome;
94 95 }
  96 +
  97 + /**
  98 + * @return BelongsToMany
  99 + */
  100 + public function grades()
  101 + {
  102 + return $this->belongsToMany(
  103 + LegacyLevel::class,
  104 + 'pmieducar.escola_serie',
  105 + 'ref_cod_escola',
  106 + 'ref_cod_serie'
  107 + )->withPivot('ativo', 'anos_letivos');
  108 + }
  109 +
  110 + /**
  111 + * @return HasMany
  112 + */
  113 + public function schoolClasses()
  114 + {
  115 + return $this->hasMany(LegacySchoolClass::class, 'ref_ref_cod_escola');
  116 + }
95 117 }
... ...
app/Models/LegacyStudent.php
... ... @@ -21,7 +21,7 @@ class LegacyStudent extends Model
21 21 * @var array
22 22 */
23 23 protected $fillable = [
24   - 'ref_idpes', 'data_cadastro',
  24 + 'ref_idpes', 'data_cadastro', 'tipo_responsavel',
25 25 ];
26 26  
27 27 /**
... ... @@ -30,6 +30,26 @@ class LegacyStudent extends Model
30 30 public $timestamps = false;
31 31  
32 32 /**
  33 + * @inheritDoc
  34 + */
  35 + protected static function boot()
  36 + {
  37 + parent::boot();
  38 +
  39 + static::creating(function ($model) {
  40 + $model->data_cadastro = now();
  41 + });
  42 + }
  43 +
  44 + /**
  45 + * @return BelongsTo
  46 + */
  47 + public function individual()
  48 + {
  49 + return $this->belongsTo(LegacyIndividual::class, 'ref_idpes');
  50 + }
  51 +
  52 + /**
33 53 * @return BelongsTo
34 54 */
35 55 public function person()
... ...
app/Models/LegacyVacancyReservationCandidate.php 0 → 100644
... ... @@ -0,0 +1,84 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Model;
  6 +use Illuminate\Database\Eloquent\Relations\BelongsTo;
  7 +
  8 +class LegacyVacancyReservationCandidate extends Model
  9 +{
  10 + /**
  11 + * @var string
  12 + */
  13 + protected $table = 'pmieducar.candidato_reserva_vaga';
  14 +
  15 + /**
  16 + * @var string
  17 + */
  18 + protected $primaryKey = 'cod_candidato_reserva_vaga';
  19 +
  20 + /**
  21 + * @var array
  22 + */
  23 + protected $fillable = [
  24 + 'ano_letivo',
  25 + 'data_solicitacao',
  26 + 'ref_cod_aluno',
  27 + 'ref_cod_serie',