git add .

git commit "Implement admin roles and permissions system"
This commit is contained in:
2026-08-18 14:07:35 +03:30
parent 78a3b1d63d
commit bff0c7ea4d
8 changed files with 307 additions and 12 deletions
+15 -10
View File
@@ -10,10 +10,10 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class AdminRole
*
*
* @property int $admin_id
* @property int $role_id
*
*
* @property Admin $admin
* @property Role $role
*
@@ -31,13 +31,18 @@ class AdminRole extends Model
'role_id' => 'int'
];
public function admin()
{
return $this->belongsTo(Admin::class);
}
public function roles()
{
return $this->belongsToMany(Role::class, 'admin_roles');
}
public function role()
{
return $this->belongsTo(Role::class);
}
public function hasPermission($permission)
{
return $this->roles()
->whereHas('permissions', function ($query) use ($permission) {
$query->where('slug', $permission);
})
->exists();
}
}