Skip to content

get a list of roles with their users and permissions #1938

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

You must be logged in to vote

Read sources too always
$roles = Role::with('permissions','users')->get();

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')
);
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@moecods
Comment options

@erikn69
Comment options

@erikn69
Comment options

Answer selected by moecods
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