Replies: 1 comment 2 replies
-
Did you add the You don't need public function roles() {
return $this->hasMany(
config('permission.models.role'),
'role_id',
'id'
);
) Now when you assign, find all roles with childs $ids=[];
Roles::with('roles')->whereIn($ids_to_assign)->get()->each(function($role)use(&$ids){
$ids[]=$role->id;
$ids=array_merge($ids,$role->roles->pluck('id')->toArray());
});
$user->syncRoles(array_unique($ids)); |
Beta Was this translation helpful? Give feedback.
2 replies
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.
-
Hi,
I want to ask how I can group multiple roles into one? For example I've got multiple reports in my application like:
and I got roles like
and I want to group them in a role that is named like
How can I do this? I already added the
HasRoles
trait to Roles model but it doesn't work. Thank you.Beta Was this translation helpful? Give feedback.
All reactions