This commit is contained in:
155
api/app/Models/Cadastro/Estabelecimento/Unidade.php
Normal file
155
api/app/Models/Cadastro/Estabelecimento/Unidade.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Models\Almoxarifado\SaidaRequisicao;
|
||||
use App\Models\Bpa\Procedimento;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Paciente;
|
||||
use App\Models\Cadastro\SujeitoAtencao\ProntuarioUnidade;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Usuario;
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento;
|
||||
use App\Models\ExameImagem\CotaPrestador;
|
||||
use App\Models\ExameImagem\Fechamento\Faturamento;
|
||||
use App\Models\ExameImagem\Jornada\Jornada;
|
||||
use App\Models\ExameImagem\Parametrizacao;
|
||||
use App\Models\ExameLaboratorial\Parametrizacao\Cota;
|
||||
use App\Models\ExameLaboratorial\Parametrizacao\Unidade as ExameLaboratorialUnidade;
|
||||
use App\Models\Model;
|
||||
use App\Models\ProntoAtendimento\Atendimento\Recepcao;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Unidade extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_unidade';
|
||||
|
||||
protected $casts = [
|
||||
'pertence_sus' => 'boolean',
|
||||
'unidade_referencia' => 'boolean',
|
||||
'unidade_prestadora' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'nome_fantasia',
|
||||
'razao_social',
|
||||
'cnpj',
|
||||
'email',
|
||||
'site',
|
||||
'tipo_id',
|
||||
'esfera_administrativa_id',
|
||||
'natureza_juridica_id',
|
||||
'cnes',
|
||||
'pertence_sus',
|
||||
'unidade_referencia',
|
||||
'unidade_prestadora',
|
||||
'gestor_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',
|
||||
];
|
||||
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(UnidadeTipo::class);
|
||||
}
|
||||
|
||||
public function exameLaboratorialUnidade()
|
||||
{
|
||||
return $this->hasOne(ExameLaboratorialUnidade::class);
|
||||
}
|
||||
|
||||
public function exameLaboratorialUnidadeCotas()
|
||||
{
|
||||
return $this->hasOne(Cota::class);
|
||||
}
|
||||
|
||||
public function esferaAdministrativa()
|
||||
{
|
||||
return $this->belongsTo(EsferaAdministrativa::class);
|
||||
}
|
||||
|
||||
public function naturezaJuridica()
|
||||
{
|
||||
return $this->belongsTo(NaturezaJuridica::class);
|
||||
}
|
||||
|
||||
public function gestor()
|
||||
{
|
||||
return $this->belongsTo(Usuario::class);
|
||||
}
|
||||
|
||||
public function infraestruturas()
|
||||
{
|
||||
return $this->hasMany(Infraestrutura::class);
|
||||
}
|
||||
|
||||
public function parametrizacaoExameImagem()
|
||||
{
|
||||
return $this->hasOne(Parametrizacao::class);
|
||||
}
|
||||
|
||||
public function jornadaExameImagem()
|
||||
{
|
||||
return $this->hasMany(Jornada::class);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(Agendamento::class);
|
||||
}
|
||||
|
||||
public function faturamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(Faturamento::class);
|
||||
}
|
||||
|
||||
public function cotaPrestadorExameImagem()
|
||||
{
|
||||
return $this->hasMany(CotaPrestador::class);
|
||||
}
|
||||
|
||||
public function pacientes()
|
||||
{
|
||||
return $this->hasMany(Paciente::class);
|
||||
}
|
||||
|
||||
public function prontuariosUnidade()
|
||||
{
|
||||
return $this->hasMany(ProntuarioUnidade::class);
|
||||
}
|
||||
|
||||
public function recepcoes()
|
||||
{
|
||||
return $this->hasMany(Recepcao::class, 'unidade_encaminhamento_id');
|
||||
}
|
||||
|
||||
public function procedimentos()
|
||||
{
|
||||
return $this->hasMany(Procedimento::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoSaidaRequisicoes()
|
||||
{
|
||||
return $this->hasMany(SaidaRequisicao::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'infraestruturas',
|
||||
'pacientes',
|
||||
'prontuariosUnidade',
|
||||
'recepcoes',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user