-
Thanks for all your efforts to provide this comprehensive library! I understand that after you have enabled the team feature, the team_id is always required whenever you need to check a permission or a role, if you don't set a team_id by using setPermissionsTeamId(current_team_id), then you will have no access to anything. I have some teams, each team has its own team leader and members. A user may be a team leader for one team and also be a member of another team. I have a manager role who is managing all the teams. Based on the suggestion of creating a superuser (https://spatie.be/docs/laravel-permission/v5/basic-usage/teams-permissions), I have created a global role (team id is NULL) called "manager", and when there is a new team being created, I will assign a "manager" role along with the new team id to this manager user. So the manager user will have access to this new team, and he has the "manager" role in this new team. If the above settings are correct and it's the expected settings, then I have a question. In my design, there is a dashboard that shows some figures like how many members for each team, who are the members and who is the team leader. So when viewing this dashboard page, what permission should I check for? This dashboard is showing figures of all teams, not any individual team, but seems there is no "global role" without team_id. So I believe I should randomly pick an existing team_id and check for the manager role. That's because the manager user is supposed to have a manager role for every team. Do you think this is the best way to do it? or do you have a simple and better solution? or better design to handle a global admin user permission to manage everything (so on top of the individual team). Thank you guys! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
If i understood
#1935 Makes a relation on team, and add #1948 Maybe informative |
Beta Was this translation helpful? Give feedback.
If i understood
#1935 Makes a relation on team, and add
withCount(['roles as users_count'=>fn($q)=>your_custom_logic_with_distinct])
and usewith
for get members, team leader, etc#1948 Maybe informative