Migrating from Shield's groups
Shield keeps groups and permissions in app/Config/AuthGroups.php, a file that changes only with a deploy. RoleWarden moves them into the database. If your application already uses Shield's groups, the move is automatic and reversible.
What the import does
Among the module's migrations, one reads your app/Config/AuthGroups.php (its $groups, $permissions and $matrix) and the assignments in Shield's auth_groups_users table, and turns them into roles, permissions and role assignments. It runs with the others:
php spark migrate -n RoleWarden
- Each group becomes a role with the same slug, name and description, holding the permissions
$matrixgives it. Wildcards such asusers.*are expanded to the matching permissions. - Each permission of
$permissionsbecomes a permission. - Each user keeps the groups they had, now as roles.
Groups with the same name as a system role
RoleWarden seeds three system roles: super-admin, admin and user. A group with one of those slugs (Shield's stock admin and user, most often) is skipped, with its assignments: the import never changes what an existing role can do. After the migration, give those users the matching role from the panel, or with the super-admin query in Installation.
Your code
Calls written for Shield keep working once $userProvider points at RoleWarden's model (see Wiring):
auth()->user()->can('posts.edit'); // now answered from the database
auth()->user()->inGroup('editor'); // reads the user's roles
Replace inGroup() with permission checks as you go: a role can be renamed or split from the panel, a permission check survives it. For pages, the can filter replaces Shield's group and permission filters.
From now on, change roles and their permissions in the panel, not in AuthGroups.php: the file is read once, by the import, and later edits to it are ignored. Keep Shield's $defaultGroup pointing at a group that exists in the file; the role new users receive is the panel's default role setting.
Going back
Rolling back RoleWarden's batch (see Installation) removes exactly what the import created, by slug, and never touches a role or permission it did not create. Shield's auth_groups_users table is only read, never changed, so Shield's groups work again as soon as $userProvider points back at Shield's model.