Replies: 2 comments 1 reply
-
You could do it by iterating over all teams. Perhaps something like this: $user = User::find(1)->get();
$permissionsPerTeam = [];
foreach (TeamModel::all() as $team) {
setPermissionsTeamId($team->id);
$user->load(['roles', 'roles.permissions', 'permissions']);
$permissionsPerTeam[$team->id] = $user->getAllPermissions()->pluck('name');
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
You could also make a new relation without teams public function all_roles()
{
return $this->morphToMany(
config('permission.models.role'),
'model',
config('permission.table_names.model_has_roles'),
config('permission.column_names.model_morph_key'),
app(PermissionRegistrar::class)->pivotRole
);
} Now $user = User::with('all_roles')->get(); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a built-in way to show all roles a user has across all teams?
For audit/inspection purposes
Beta Was this translation helpful? Give feedback.
All reactions