80 lines
1.7 KiB
PHP
80 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Administracao;
|
|
|
|
use App\Models\Cadastro\SujeitoAtencao\Lotacao;
|
|
use App\Models\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Papel extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'administracao_papel';
|
|
|
|
protected $fillable = [
|
|
'nome',
|
|
];
|
|
|
|
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',
|
|
];
|
|
|
|
protected $with = [
|
|
'permissoes',
|
|
];
|
|
|
|
public function permissoes()
|
|
{
|
|
return $this
|
|
->belongsToMany(
|
|
Permissao::class,
|
|
'administracao_papel_permissao',
|
|
'papel_id',
|
|
'permissao_id'
|
|
)
|
|
->using(PapelPermissao::class)
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function lotacoes()
|
|
{
|
|
return $this
|
|
->belongsToMany(
|
|
Lotacao::class,
|
|
'administracao_lotacao_papel',
|
|
'papel_id',
|
|
'lotacao_id'
|
|
)
|
|
->using(LotacaoPapel::class)
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function gestores()
|
|
{
|
|
return $this
|
|
->belongsToMany(
|
|
Gestor::class,
|
|
'administracao_gestor_papel',
|
|
'papel_id',
|
|
'gestor_id'
|
|
)
|
|
->using(GestorPapel::class)
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function getIsAllowedToDeleteAttribute()
|
|
{
|
|
return true;
|
|
}
|
|
}
|