This commit is contained in:
48
api/app/Models/Cadastro/Localizacao/Bairro.php
Normal file
48
api/app/Models/Cadastro/Localizacao/Bairro.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Bairro extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_bairro';
|
||||
|
||||
protected $fillable = [
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'deleted_at',
|
||||
'deleted_lotacao_id',
|
||||
'deleted_centro_custo_id',
|
||||
];
|
||||
|
||||
public function logradouros()
|
||||
{
|
||||
return $this->hasMany(Logradouro::class);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(Agendamento::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'logradouros'
|
||||
]);
|
||||
}
|
||||
}
|
||||
64
api/app/Models/Cadastro/Localizacao/Domicilio.php
Normal file
64
api/app/Models/Cadastro/Localizacao/Domicilio.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\AtencaoBasica\CadastroDomiciliar\CadastroDomiciliar;
|
||||
use App\Models\Cadastro\Localizacao\DomicilioInformacaoResidencial;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Cidadao;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Domicilio extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_domicilio';
|
||||
|
||||
protected $fillable = [
|
||||
'endereco_id'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'deleted_at',
|
||||
'deleted_lotacao_id',
|
||||
'deleted_centro_custo_id',
|
||||
'endereco_id'
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'endereco'
|
||||
];
|
||||
|
||||
public function endereco()
|
||||
{
|
||||
return $this->belongsTo(Endereco::class);
|
||||
}
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'cidadaos',
|
||||
]);
|
||||
}
|
||||
|
||||
public function cadastroDomiciliar()
|
||||
{
|
||||
return $this->hasOne(CadastroDomiciliar::class);
|
||||
}
|
||||
|
||||
public function informacaoResidencial()
|
||||
{
|
||||
return $this->hasOne(DomicilioInformacaoResidencial::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\AtencaoBasica\CadastroDomiciliar\Animal;
|
||||
use App\Models\AtencaoBasica\CadastroDomiciliar\Lazer;
|
||||
use App\Models\Cadastro\Localizacao\DomicilioInformacaoResidencialAnimal;
|
||||
use App\Models\Cadastro\Localizacao\DomicilioInformacaoResidencialLazer;
|
||||
use App\Models\Model;
|
||||
use App\Models\Sigtap\Ocupacao;
|
||||
|
||||
class DomicilioInformacaoResidencial extends Model
|
||||
{
|
||||
|
||||
protected $table = 'cadastro_domicilio_informacao_residencial';
|
||||
|
||||
protected $casts = [
|
||||
'instituicao_outros_profissionais' => 'boolean',
|
||||
'possui_animais' => 'boolean',
|
||||
'bolsa_familia' => 'boolean',
|
||||
'vale_gas' => 'boolean',
|
||||
'bolsa_escola' => 'boolean',
|
||||
'bpc' => 'boolean',
|
||||
'recusa_cadastro' => 'boolean',
|
||||
'fora_area' => 'boolean',
|
||||
'energia_eletrica' => 'boolean',
|
||||
'possui_veiculo_proprio' => 'boolean',
|
||||
'possui_financiamento' => 'boolean',
|
||||
'possui_emprestimo' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'domicilio_id',
|
||||
'microarea_id',
|
||||
'fora_area',
|
||||
'instituicao_nome',
|
||||
'instituicao_outros_profissionais',
|
||||
'instituicao_nome_responsavel_tecnico',
|
||||
'instituicao_cns_responsavel_tecnico',
|
||||
'instituicao_cargo_responsavel_tecnico',
|
||||
'instituicao_telefone_responsavel_tecnico',
|
||||
'imovel_tipo_id',
|
||||
'situacao_domicilio_id',
|
||||
'domicilio_tipo_id',
|
||||
'quantidade_comodos',
|
||||
'situacao_rural_id',
|
||||
'domicilio_zona_id',
|
||||
'domicilio_tipo_acesso_id',
|
||||
'material_predominante_id',
|
||||
'abastecimento_id',
|
||||
'tratamento_id',
|
||||
'destino_lixo_id',
|
||||
'forma_escoamento_id',
|
||||
'possui_animais',
|
||||
'quantidade_animais',
|
||||
'energia_eletrica',
|
||||
'higiene_residencial_id',
|
||||
'bolsa_familia',
|
||||
'vale_gas',
|
||||
'bolsa_escola',
|
||||
'bpc',
|
||||
'escala_coelho_id',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function lazer()
|
||||
{
|
||||
return $this->belongsToMany(Lazer::class, 'cadastro_domicilio_informacao_residencial_lazer')
|
||||
->using(DomicilioInformacaoResidencialLazer::class)
|
||||
->as('DomicilioInformacaoResidencialLazer')
|
||||
->withPivot(
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'domicilio_informacao_residencial_id',
|
||||
'lazer_id',
|
||||
)
|
||||
->select('atencao_basica_cadastro_lazer.id')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function animal()
|
||||
{
|
||||
return $this->belongsToMany(Animal::class, 'cadastro_domicilio_informacao_residencial_animal')
|
||||
->using(DomicilioInformacaoResidencialAnimal::class)
|
||||
->as('DomicilioInformacaoResidencialAnimal')
|
||||
->withPivot(
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'domicilio_informacao_residencial_id',
|
||||
'animal_id',
|
||||
)
|
||||
->select('atencao_basica_cadastro_animal.id')
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class DomicilioInformacaoResidencialAnimal extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'animal_id',
|
||||
'domicilio_informacao_residencial_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class DomicilioInformacaoResidencialLazer extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'lazer_id',
|
||||
'domicilio_informacao_residencial_id',
|
||||
];
|
||||
}
|
||||
106
api/app/Models/Cadastro/Localizacao/Endereco.php
Normal file
106
api/app/Models/Cadastro/Localizacao/Endereco.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Endereco extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_endereco';
|
||||
|
||||
protected $fillable = [
|
||||
'logradouro_id',
|
||||
'numero',
|
||||
'complemento',
|
||||
'referencia',
|
||||
'loteamento_id',
|
||||
'zona_id',
|
||||
'latitude',
|
||||
'longitude',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'deleted_at',
|
||||
'deleted_lotacao_id',
|
||||
'deleted_centro_custo_id',
|
||||
'logradouro_id',
|
||||
'loteamento_id',
|
||||
'zona_id',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'sem_numero',
|
||||
'completo',
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'logradouro',
|
||||
'loteamento',
|
||||
'zona',
|
||||
];
|
||||
|
||||
public function logradouro()
|
||||
{
|
||||
return $this->belongsTo(Logradouro::class);
|
||||
}
|
||||
|
||||
public function loteamento()
|
||||
{
|
||||
return $this->belongsTo(Loteamento::class);
|
||||
}
|
||||
|
||||
public function zona()
|
||||
{
|
||||
return $this->belongsTo(Zona::class);
|
||||
}
|
||||
|
||||
public function infraestruturas()
|
||||
{
|
||||
return $this->hasMany(Infraestrutura::class);
|
||||
}
|
||||
|
||||
public function domicilios()
|
||||
{
|
||||
return $this->hasMany(Domicilio::class);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(Agendamento::class);
|
||||
}
|
||||
|
||||
public function getSemNumeroAttribute()
|
||||
{
|
||||
return is_null($this->numero);
|
||||
}
|
||||
|
||||
public function getCompletoAttribute()
|
||||
{
|
||||
$tipo = $this->logradouro->tipo->descricao;
|
||||
$logradouro = $this->logradouro->nome;
|
||||
$numero = $this->sem_numero ? 'S/N' : $this->numero;
|
||||
$bairro = $this->logradouro->bairro->nome;
|
||||
$municipio = $this->logradouro->municipio->nome;
|
||||
$uf = $this->logradouro->municipio->estado->uf;
|
||||
|
||||
return "{$tipo} {$logradouro}, {$numero} - {$bairro}, {$municipio} - {$uf}";
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'infraestruturas',
|
||||
'domicilios',
|
||||
]);
|
||||
}
|
||||
}
|
||||
85
api/app/Models/Cadastro/Localizacao/Logradouro.php
Normal file
85
api/app/Models/Cadastro/Localizacao/Logradouro.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento;
|
||||
use App\Models\Intranet\Municipio;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Logradouro extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_logradouro';
|
||||
|
||||
protected $fillable = [
|
||||
'municipio_id',
|
||||
'bairro_id',
|
||||
'tipo_id',
|
||||
'nome',
|
||||
'cep'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'deleted_at',
|
||||
'deleted_lotacao_id',
|
||||
'deleted_centro_custo_id',
|
||||
'municipio_id',
|
||||
'bairro_id',
|
||||
'tipo_id'
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'tipo',
|
||||
'bairro',
|
||||
'municipio'
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'tipo_nome',
|
||||
];
|
||||
|
||||
public function municipio()
|
||||
{
|
||||
return $this->belongsTo(Municipio::class);
|
||||
}
|
||||
|
||||
public function bairro()
|
||||
{
|
||||
return $this->belongsTo(Bairro::class);
|
||||
}
|
||||
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(LogradouroTipo::class);
|
||||
}
|
||||
|
||||
public function enderecos()
|
||||
{
|
||||
return $this->hasMany(Endereco::class);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(Agendamento::class);
|
||||
}
|
||||
|
||||
public function getTipoNomeAttribute()
|
||||
{
|
||||
return "{$this->tipo->descricao} {$this->nome}";
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'enderecos'
|
||||
]);
|
||||
}
|
||||
}
|
||||
26
api/app/Models/Cadastro/Localizacao/LogradouroTipo.php
Normal file
26
api/app/Models/Cadastro/Localizacao/LogradouroTipo.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class LogradouroTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_logradouro_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'codigo',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function logradouros()
|
||||
{
|
||||
return $this->hasMany(Logradouro::class, 'tipo_id');
|
||||
}
|
||||
}
|
||||
41
api/app/Models/Cadastro/Localizacao/Loteamento.php
Normal file
41
api/app/Models/Cadastro/Localizacao/Loteamento.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Loteamento extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_loteamento';
|
||||
|
||||
protected $fillable = [
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'deleted_at',
|
||||
'deleted_lotacao_id',
|
||||
'deleted_centro_custo_id',
|
||||
];
|
||||
|
||||
public function enderecos()
|
||||
{
|
||||
return $this->hasMany(Endereco::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'enderecos'
|
||||
]);
|
||||
}
|
||||
}
|
||||
26
api/app/Models/Cadastro/Localizacao/Zona.php
Normal file
26
api/app/Models/Cadastro/Localizacao/Zona.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Zona extends Model
|
||||
{
|
||||
protected $table = 'cadastro_zona';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'codigo_esus'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function enderecos()
|
||||
{
|
||||
return $this->hasMany(Endereco::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user