Replies: 17 comments
-
you can assign multiple Roles to the same user |
Beta Was this translation helpful? Give feedback.
-
@dennis-git sure, but it doesn't solve the issue. At best, it's a workaround. |
Beta Was this translation helpful? Give feedback.
-
@hawezo I am agree with you, I really need this feature in my project |
Beta Was this translation helpful? Give feedback.
-
I would need that feature as well. |
Beta Was this translation helpful? Give feedback.
-
What type of inheritance are you needed to implement? |
Beta Was this translation helpful? Give feedback.
-
In my case, if a role like If by multiple inheritance you mean that a role would be able to inherit multiple other roles, I don't personally need it, but I'm sure that it'd be a useful feature. |
Beta Was this translation helpful? Give feedback.
-
While not entirely the same as "group inheritance" discussed here, it's worth looking at #1381, released in 3.9.0. |
Beta Was this translation helpful? Give feedback.
-
Technically you could implement this in your own application during setup of the roles and permissions (see below). Granted, it is not done at runtime, but the problem with doing this at runtime is that it will require another relationship to be implemented. For every relationship implemented, another performance hit has to be taken. // First Option: Existing Role
$moderator = Role::create([ 'name' => 'Moderator' ]);
$moderator->givePermissionTo(
Role::findByName('User')->permissions->merge([
Permission::findByName('post.edit'),
Permission::findByName('post.delete'),
])
);
// Second Option: Create them all at once
$userPermissions = collect([
'post.create',
]);
$moderatorPermissions = $userPermissions->merge([
'post.edit',
'post.delete',
]);
$user = Role::create([ 'name' => 'User' ]);
$user->givePermissionTo( $userPermissions );
$moderator = Role::create([ 'name' => 'Moderator' ]);
$moderator->givePermissionTo( $moderatorPermissions ); |
Beta Was this translation helpful? Give feedback.
-
There has been multiple requests for this (#128, #161) and they didn't result in an implementation because this feature was thought to not be needed for most users.
However, I think it is pretty common to have a role inheritance, as previous suggestions explained: an administrator would inherit lower roles. This would avoid having to manually apply each permission to every role, or adding roles like
moderator
anduser
toadministrator
.I know you guys would like to keep things as simple as possible, but this is the permission package and I think this feature would be really appreciated. Thank you 😊
Beta Was this translation helpful? Give feedback.
All reactions