Best way to load child/parent roles and permissions? #2081
Unanswered
Sean-OShea
asked this question in
Q&A
Replies: 0 comments
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.
-
Hi everyone,
My use case is that i have a hierarchy of users. And sometimes i need to check the permission of a child or parent user. I've been surprised that none of those works (please correct me if i'm wrong).
protected $with = ['roles.permissions', 'permissions'];
Because i don't want to have to explicitly eager load every time i get my user's parent, here is the method i use :
Am i missing something? I feel like it must be a common use case but i haven't found a discussion on that specific parent/child relationship. Thanks everyone and have a nice day.
Sean.
Edit : i must specify that i'm also using the team feature, but a user hierarchy always share the same team_id (and it is set on each request with a middleware for the authenticated user as described in the documentation).
Beta Was this translation helpful? Give feedback.
All reactions