This package allows you to manage user permissions and roles in a database.
Step 1: Install the Package
Run the composer command to install the Spatie permission package:
After installing, publish the config and migration files:
You will see:
- config/permission.php → Configuration file
Migration files for tables:
- roles
- permissions
- model_has_roles
- model_has_permissions
- role_has_permissions
Step 2: Run Migrations
Run the migrations to create tables:
Now your database will have the required tables for roles and permissions.
Step 3: Add the Trait to User Model
Open your User model and add the HasRoles trait:
