This project provides a basic setup for using Spatie's Laravel Permissions and Roles package. Preferable to use Admin account to see the features.
Before running the project, make sure to run the following commands to set up the database tables with sample data:
cd laravel-admin-spatie-example
composer install
cp .env.example .env
php artisan key:generate
php artisan migrate:fresh --seed
This will create some sample users with different roles and permissions.
Here are the email addresses and passwords for the sample users along with their corresponding roles and permissions:
-
Admin User:
- Email: [email protected]
- Password: password
- Role: admin
- Permissions: write post, publish post, edit post
-
Writer User:
- Email: [email protected]
- Password: password
- Role: writer
- Permissions: write post, publish post
-
Editor User:
- Email: [email protected]
- Password: password
- Role: editor
- Permissions: edit post
-
Publisher User:
- Email: [email protected]
- Password: password
- Role: publisher
- Permissions: publish post
Feel free to log in with any of these users to explore the application.
In the seeding process, the following roles and permissions are created:
-
Roles:
- admin
- writer
- editor
- publisher
-
Permissions:
- write post
- edit post
- publish post
Roles are assigned permissions as follows:
- The admin role has permissions to write, publish, and edit posts.
- The writer role has permissions to write and publish posts.
- The editor role has permission to edit posts.
- The publisher role has permission to publish posts.