fix(rbac): resolve custom role blank view and clarify default vs direct permissions

This commit is contained in:
Ray1111-aa
2026-10-20 14:41:57 +07:00
parent 33d72889be
commit dc1b117922
8 changed files with 338 additions and 157 deletions
+7 -3
View File
@@ -120,8 +120,8 @@ class User extends Authenticatable
return $emp;
}
// Jika user memiliki role employee atau admin yang memerlukan profil operasional
if ($this->isEmployee() || $this->isSuperAdmin()) {
// Jika user memiliki role employee, wewenang operasional karyawan, atau admin
if ($this->isEmployee() || $this->can('employee.dashboard') || $this->can('employee.timesheet') || $this->can('employee.p2h') || $this->isSuperAdmin()) {
return Employee::create([
'user_id' => $this->id,
'nik' => $this->username,
@@ -139,7 +139,11 @@ class User extends Authenticatable
public function isEmployee(): bool
{
return $this->role === 'employee' || $this->hasRole('employee');
return $this->role === 'employee'
|| $this->hasRole('employee')
|| $this->can('employee.dashboard')
|| $this->can('employee.timesheet')
|| $this->can('employee.p2h');
}
public function isGateOfficer(): bool