Query scopes for role based permissions #2807
-
Is there any way to query the user model based on permissions via roles? |
Beta Was this translation helpful? Give feedback.
Answered by
drbyte
Feb 15, 2025
Replies: 1 comment
-
https://spatie.be/docs/laravel-permission/v6/basic-usage/basic-usage#content-scopes $users = User::permission('edit articles')->get(); // Returns only users with the permission 'edit articles' (inherited or directly)
$usersWhoCannotEditArticles = User::withoutPermission('edit articles')->get(); // Returns all users without the permission 'edit articles' (inherited or directly) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sabina1997
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://spatie.be/docs/laravel-permission/v6/basic-usage/basic-usage#content-scopes