52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Cadastro\SujeitoAtencao;
|
|
|
|
use App\Models\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Alergia extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'cadastro_alergia';
|
|
|
|
protected $fillable = [
|
|
'tipo_id',
|
|
'agente_substancia_especifica',
|
|
];
|
|
|
|
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',
|
|
'pivot'
|
|
];
|
|
|
|
public function tipo()
|
|
{
|
|
return $this->belongsTo(AlergiaTipo::class);
|
|
}
|
|
|
|
public function cidadaos()
|
|
{
|
|
return $this->belongsToMany(Cidadao::class, 'cadastro_cidadao_alergia')
|
|
->using(CidadaoAlergia::class)
|
|
->withPivot('criticidade_id', 'reacoes_observacoes', 'cid_id')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function getIsAllowedToDeleteAttribute()
|
|
{
|
|
return $this->hasNoOne([
|
|
'cidadaos',
|
|
]);
|
|
}
|
|
}
|