54 lines
1.0 KiB
PHP
54 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Cadastro\Estabelecimento;
|
|
|
|
use App\Models\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Setor extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'cadastro_setor';
|
|
|
|
protected $fillable = [
|
|
'tipo_id',
|
|
'servico_id',
|
|
'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',
|
|
];
|
|
|
|
public function tipo()
|
|
{
|
|
return $this->belongsTo(SetorTipo::class);
|
|
}
|
|
|
|
public function servico()
|
|
{
|
|
return $this->belongsTo(Servico::class);
|
|
}
|
|
|
|
public function centrosCusto()
|
|
{
|
|
return $this->hasMany(CentroCusto::class);
|
|
}
|
|
|
|
public function getIsAllowedToDeleteAttribute()
|
|
{
|
|
return $this->hasNoOne([
|
|
'centrosCusto',
|
|
]);
|
|
}
|
|
}
|