Hello,
I'm seeding 113 permissions and 20 roles, currently I'm doing this through a foreach guard loop.
My suggestion is to maybe allow the following syntax?
// Create a superadmin role for the admin users
$role = Role::create(['guard_name' => ['admin', 'web', 'api'], 'name' => 'superadmin']);
// Define a `publish articles` permission for the admin users belonging to the admin guard
$permission = Permission::create(['guard_name' => ['admin', 'web', 'api'], 'name' => 'publish articles']);
// Define a *different* `publish articles` permission for the regular users belonging to the web guard
$permission = Permission::create(['guard_name' => ['admin', 'web', 'api'], 'name' => 'publish articles']);
Refer to current documentation syntax:
// Create a superadmin role for the admin users
$role = Role::create(['guard_name' => 'admin', 'name' => 'superadmin']);
// Define a `publish articles` permission for the admin users belonging to the admin guard
$permission = Permission::create(['guard_name' => 'admin', 'name' => 'publish articles']);
// Define a *different* `publish articles` permission for the regular users belonging to the web guard
$permission = Permission::create(['guard_name' => 'web', 'name' => 'publish articles']);
Just to be clear, am I correct in observing that you are creating identical sets of roles and permissions for every guard?
And that if this package were to allow the guard factor to simply pass through to your app and allow the app take care of guard logic, that the roles/permissions would stand as sufficient on their own?
I find that the vast majority of apps are in exactly this situation, and therefore plans are that a future version of this package will be dropping logic for intercepting and defining guard-specific Authorization activities, and allow the app to handle that part.
Yes Sir,
I'm following principles of DDD - a manager via API or WEB should be able to do identical actions - just different mediums, thus is why I end up having to duplicate Roles and Permissions over guards.
Great! I think you'll like the simplification of a future "new version" with guard-specific logic removed.
We have a few more things to sort out with it, so unfortunately it's not quite ready to go yet.
Thanks for sharing your suggestion. Fortunately it should become moot when that new version is ready.
I have a use case for this causing the code to be a bit ugly.. not sure why this was closed or not linked to a different issue.
I hope v3 releases soon 馃槃
It sounds like I need the guard handling logic coming in v3. What's the timeline for release? (Happy to help out if I can.)
+1
+1
+1
Any news on this one?
i want to create multiple permissions for one role with single command how could i?
Most helpful comment
Great! I think you'll like the simplification of a future "new version" with guard-specific logic removed.
We have a few more things to sort out with it, so unfortunately it's not quite ready to go yet.
Thanks for sharing your suggestion. Fortunately it should become moot when that new version is ready.