This commit is contained in:
132
api/app/Models/Cadastro/Estabelecimento/Infraestrutura.php
Normal file
132
api/app/Models/Cadastro/Estabelecimento/Infraestrutura.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Models\Ambulatorio\ParametrizacaoInfraestrutura as AmbulatorioParametrizacaoInfraestrutura;
|
||||
use App\Models\Cadastro\Localizacao\Endereco;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Lotacao;
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento;
|
||||
use App\Models\ExameImagem\CotaPrestador;
|
||||
use App\Models\ExameImagem\Jornada\Jornada;
|
||||
use App\Models\ExameImagem\Parametrizacao;
|
||||
use App\Models\ExameLaboratorial\Parametrizacao\Unidade as ExameLaboratorialUnidade;
|
||||
use App\Models\ExameLaboratorial\Parametrizacao\UnidadeSolicitanteExame;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Infraestrutura extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_infraestrutura';
|
||||
|
||||
protected $casts = [
|
||||
'principal' => 'boolean',
|
||||
'ativo' => 'boolean'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'infraestrutura_id',
|
||||
'principal',
|
||||
'nome',
|
||||
'telefone',
|
||||
'ativo',
|
||||
'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',
|
||||
'unidade_id',
|
||||
'endereco_id',
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'endereco'
|
||||
];
|
||||
|
||||
public function parametrizacaoExameImagem()
|
||||
{
|
||||
return $this->hasOne(Parametrizacao::class);
|
||||
}
|
||||
|
||||
public function jornadaExameImagem()
|
||||
{
|
||||
return $this->hasMany(Jornada::class);
|
||||
}
|
||||
|
||||
public function cotaPrestadorExameImagem()
|
||||
{
|
||||
return $this->hasOne(CotaPrestador::class);
|
||||
}
|
||||
|
||||
public function unidade()
|
||||
{
|
||||
return $this->belongsTo(Unidade::class);
|
||||
}
|
||||
|
||||
public function infraestrutura()
|
||||
{
|
||||
return $this->belongsTo(Infraestrutura::class);
|
||||
}
|
||||
|
||||
public function exameLaboratorialUnidade()
|
||||
{
|
||||
return $this->hasOne(ExameLaboratorialUnidade::class);
|
||||
}
|
||||
|
||||
public function exameLaboratorialUnidadeSolicitanteExame()
|
||||
{
|
||||
return $this->hasOne(UnidadeSolicitanteExame::class);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasOne(Agendamento::class);
|
||||
}
|
||||
|
||||
public function exameLaboratorialUnidadeCotas()
|
||||
{
|
||||
return $this->hasOne(Cota::class);
|
||||
}
|
||||
|
||||
public function endereco()
|
||||
{
|
||||
return $this->belongsTo(Endereco::class);
|
||||
}
|
||||
|
||||
public function centrosCusto()
|
||||
{
|
||||
return $this->hasMany(CentroCusto::class);
|
||||
}
|
||||
|
||||
public function lotacoes()
|
||||
{
|
||||
return $this->hasMany(Lotacao::class);
|
||||
}
|
||||
|
||||
public function ambulatorioParametrizacaoJornadaInfraestrutura()
|
||||
{
|
||||
return $this->hasOne(AmbulatorioParametrizacaoInfraestrutura::class);
|
||||
}
|
||||
|
||||
public function getNomeAttribute($nome)
|
||||
{
|
||||
return $this->principal ? $this->unidade->nome_fantasia : $nome;
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'centrosCusto',
|
||||
'lotacoes',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user