This commit is contained in:
51
api/app/Models/Cadastro/SujeitoAtencao/Alergia.php
Normal file
51
api/app/Models/Cadastro/SujeitoAtencao/Alergia.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user