Skip to content

Teams: Get all roles with count of users. #2013

Answered by erikn69
jackthedev asked this question in Q&A
Discussion options

You must be logged in to vote

I tried $roles = Role::where('team_id', MY_TEAM_ID)->with('users')->get();
and everything works as expected, maybe you broke something on your implementation

Looks at this

public function users(): BelongsToMany
{
return $this->morphedByMany(
getModelForGuard($this->attributes['guard_name']),
'model',
config('permission.table_names.model_has_roles'),
PermissionRegistrar::$pivotRole,
config('permission.column_names.model_morph_key')
);
}

there is no team_id = 1) on relationship, you did add that on some place and them it is ambiguous because you did add team_id on …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jackthedev
Comment options

Answer selected by jackthedev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants