fix sidebar permission user

This commit is contained in:
arifal
2025-03-10 16:33:53 +07:00
parent bf55eb228e
commit b0f15a9221
10 changed files with 190 additions and 480 deletions

View File

@@ -53,4 +53,11 @@ class User extends Authenticatable
public function roles(){
return $this->belongsToMany(Role::class, 'user_role')->withTimestamps();
}
public function menus(){
return Menu::whereHas('roles', function ($query){
$query->whereIn('roles.id', $this->roles->pluck('id'))
->where('role_menu.allow_show', true);
});
}
}