Roles and Permissions

Laratic uses the Spatie Laravel Permission package to manage user roles and permissions. Users can have multiple roles, and roles can have multiple permissions.

Managing User Roles via Admin Interface

You can assign and remove roles from users directly through the admin edit user page:

  1. Navigate to the users in the admin panel
  2. Click on a user to view their detail page
  3. Select a role from the dropdown to assign it to the user
  4. Click the X icon on the role badge to remove it from the user

The dropdown only shows roles that are not already assigned to the user, preventing duplicate assignments.

Creating an Admin User

To create a new user with the admin role:

php artisan app:create-admin-user

Managing Roles and Permissions via Artisan

Roles and permissions are created using Spatie's artisan commands. Here are the most important ones:

Creating Roles

php artisan permission:create-role developer

Creating Permissions

php artisan permission:create-permission "edit posts"

Viewing All Roles and Permissions

php artisan permission:show

For more artisan commands and advanced usage, refer to the official Spatie Laravel Permission documentation.