Replies: 1 comment
-
If I get it right, you want to find if a role with a specific id has a given permission or not. If yes, you can use the following query. const matchingRole = await Role.query().where('id', someId).whereHas('permissions', (subquery) => {
subquery.where('name', 'something')
}).first()
if (!matchingRole) {
// no match found
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to find existence of certain Permissions on a single parent Role (many-to-many).
This is the solution so far, which seems not optimal.
Is there a way to do this without loading all the roles and permissions and looping through them in Javascript?
Thank you so much 🙏
Beta Was this translation helpful? Give feedback.
All reactions