This commit is contained in:
158
api/database/seeders/9999_99_99_999999_inicial.php
Normal file
158
api/database/seeders/9999_99_99_999999_inicial.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Inicial_99999999999999 extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
DB::transaction(function () {
|
||||
|
||||
$bairro = \App\Models\Cadastro\Localizacao\Bairro::updateOrCreate(
|
||||
['nome' => 'ALTO']
|
||||
);
|
||||
|
||||
$municipio = \App\Models\Intranet\Municipio::where('nome', 'PIRACICABA')->firstOrFail();
|
||||
|
||||
$logradouroTipo = \App\Models\Cadastro\Localizacao\LogradouroTipo::where('codigo', '081')->firstOrFail();
|
||||
|
||||
$logradouro = \App\Models\Cadastro\Localizacao\Logradouro::updateOrCreate(
|
||||
[
|
||||
'municipio_id' => $municipio->id,
|
||||
'bairro_id' => $bairro->id,
|
||||
'tipo_id' => $logradouroTipo->id,
|
||||
'nome' => 'MANOEL FERRAZ DE ARRUDA CAMPOS'
|
||||
],
|
||||
[
|
||||
'cep' => '13419130'
|
||||
]
|
||||
);
|
||||
|
||||
$cidadao = \App\Models\Cadastro\SujeitoAtencao\Cidadao::updateOrCreate(
|
||||
[
|
||||
'cpf' => '68129120500',
|
||||
],
|
||||
[
|
||||
'nome' => 'ADMINISTRADOR DO SISTEMA',
|
||||
'data_nascimento' => '1969-12-31',
|
||||
'cpf' => '68129120500',
|
||||
'cidadao_id' => 1,
|
||||
'nome_mae' => 'MÁRCIA QUEIROZ',
|
||||
'frequenta_escola' => false,
|
||||
'local_nascimento_id' => 1,
|
||||
'pais_nascimento_id' => $municipio->estado->pais_id,
|
||||
'estado_nascimento_id' => $municipio->estado_id,
|
||||
'municipio_nascimento_id' => $municipio->id,
|
||||
'nacionalidade_id' => 1,
|
||||
'raca_cor_id' => 1,
|
||||
'sexo_id' => 1,
|
||||
'cns' => '157337885170001',
|
||||
],
|
||||
);
|
||||
|
||||
if ($cidadao->telefones->isEmpty()) {
|
||||
|
||||
$cidadao->telefones()->create([
|
||||
'numero' => '99999999999',
|
||||
'autoriza_sms' => false,
|
||||
'principal' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
$usuario = \App\Models\Cadastro\SujeitoAtencao\Usuario::updateOrCreate(
|
||||
[
|
||||
'cidadao_id' => $cidadao->id,
|
||||
],
|
||||
[
|
||||
'usuario' => "administrador",
|
||||
'email' => "admin@rkmsistemas.com.br",
|
||||
'senha' => '$$ConSus2025#',
|
||||
]
|
||||
);
|
||||
|
||||
$unidade = \App\Models\Cadastro\Estabelecimento\Unidade::updateOrCreate(
|
||||
[
|
||||
'cnpj' => '96547900000122'
|
||||
],
|
||||
[
|
||||
'nome_fantasia' => 'RKM SISTEMAS',
|
||||
'razao_social' => 'RKM SISTEMAS',
|
||||
'tipo_id' => 1,
|
||||
'esfera_administrativa_id' => 1,
|
||||
'natureza_juridica_id' => 1,
|
||||
'gestor_id' => $usuario->id,
|
||||
'cnes' => '9999999',
|
||||
'unidade_referencia' => true
|
||||
]
|
||||
);
|
||||
|
||||
\App\Models\Cadastro\SujeitoAtencao\Paciente::updateOrCreate(
|
||||
[
|
||||
'cidadao_id' => $cidadao->id,
|
||||
],
|
||||
[
|
||||
'unidade_id' => $unidade->id
|
||||
]
|
||||
);
|
||||
|
||||
$endereco = \App\Models\Cadastro\Localizacao\Endereco::updateOrCreate(
|
||||
[
|
||||
'logradouro_id' => $logradouro->id,
|
||||
'numero' => 565,
|
||||
'complemento' => null,
|
||||
'zona_id' => \App\Enums\Cadastro\Localizacao\Zona::URBANA,
|
||||
]
|
||||
);
|
||||
|
||||
$infraestrutura = \App\Models\Cadastro\Estabelecimento\Infraestrutura::updateOrCreate(
|
||||
[
|
||||
'unidade_id' => $unidade->id,
|
||||
'principal' => true
|
||||
],
|
||||
[
|
||||
'endereco_id' => $endereco->id,
|
||||
'telefone' => '9999999999'
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
$setor = \App\Models\Cadastro\Estabelecimento\Setor::updateOrCreate(
|
||||
[
|
||||
'tipo_id' => \App\Enums\Cadastro\Estabelecimento\SetorTipo::ADMINISTRACAO,
|
||||
'servico_id' => \App\Enums\Cadastro\Estabelecimento\Servico::NAO_SE_APLICA,
|
||||
'nome' => 'ADMINISTRACAO'
|
||||
]
|
||||
);
|
||||
|
||||
\App\Models\Cadastro\Estabelecimento\CentroCusto::updateOrCreate(
|
||||
[
|
||||
'infraestrutura_id' => $infraestrutura->id,
|
||||
'setor_id' => $setor->id
|
||||
]
|
||||
);
|
||||
|
||||
$lotacao = \App\Models\Cadastro\SujeitoAtencao\Lotacao::updateOrCreate(
|
||||
[
|
||||
'infraestrutura_id' => $infraestrutura->id,
|
||||
'usuario_id' => $usuario->id,
|
||||
'ocupacao_id' => (\App\Models\Sigtap\Ocupacao::where('codigo', '225125')->firstOrFail())->id,
|
||||
'realiza_atendimento' => true
|
||||
]
|
||||
);
|
||||
|
||||
$papel = \App\Models\Administracao\Papel::updateOrCreate(
|
||||
[
|
||||
'nome' => 'Administrador'
|
||||
]
|
||||
);
|
||||
|
||||
$papel->permissoes()->sync(\App\Models\Administracao\Permissao::pluck('id'));
|
||||
|
||||
if ($papel->wasRecentlyCreated) {
|
||||
|
||||
$lotacao->papeis()->attach($papel->id);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user