May 31, 2021
0
Level 2
Spatie Permissions - how to add a permission group?
In my User Management component, on the modal used to add/edit user information, I'd like to be able to filter permissions by a permission group name. I was thinking about adding a "group_name" colument. What would be the correct way of adding the column to the existing multi-column index. For example: The last line in the migration looks like this:
$table->unique(['name', 'guard_name']) ;
Can I insert a column name to that index using another migration or would I need to drop the index and re-create it with the third column name?
I started seeding my permissions table like this:
// Reset cached roles and permissions
app()[PermissionRegistrar::class]->forgetCachedPermissions();
Permission::create([ 'name' => 'access app settings', 'group_name' => 'app settings']);
Permission::create([ 'name' => 'edit app settings', 'group_name' => 'app settings' ]);
Permission::create([ 'name' => 'view app settings', 'group_name' => 'app settings' ]);
Permission::create([ 'name' => 'delete app settings', 'group_name' => 'app settings' ]);
Permission::create([ 'name' => 'access roles','group_name' => 'app settings']);
Permission::create([ 'name' => 'create roles' ]);
Permission::create([ 'name' => 'edit roles' ]);
Permission::create([ 'name' => 'view roles' ]);
Permission::create([ 'name' => 'delete roles' ]);
Permission::create([ 'name' => 'access permissions' ]);
Permission::create([ 'name' => 'create permissions' ]);
Permission::create([ 'name' => 'edit permissions' ]);
Permission::create([ 'name' => 'view permissions' ]);
Permission::create([ 'name' => 'delete permissions' ]);
Please or to participate in this conversation.