This project only seeks to be a guide and test for the efficient management of roles and permissions in Laravel. All of this under the Spatie Laravel-Permissions package.
- Roles and Permissions
- Authentication
- Authorization
- Policies
- Gates
- Seeder
- Factory
- Migrations
- Controllers
- Tests
- Routes
- Laravel 11
- Postgres 14
- Spatie Laravel-Permission 6.10
- Laravel Sanctum 4.0
Install and run
- Clone and move to folder
$ git clone [email protected]:abrahamuchos/roles-with-spatie-permissions.git
$ cd roles-with-spatie-permissions
- Install dependencies
$ composer install
-
Create a copy of the
.env.example
file and rename it to.env
. Next, configure the necessary environment variables. -
Generate an application key by running
php artisan key:generate
. -
Run
php artisan migrate
to create the database tables. -
Run
php artisandb:seed
to create dummy data and admin user. -
Run
php artisan serve
to start the Laravel development server. -
Run
php artisan test
to run the tests.
To run this project, you will need to add the following environment variables to your .env file
DB_HOST
DB_PORT
DB_DATABASE
DB_USERNAME
DB_PASSWORD
This documentation will serve as a guide to understand the management of Roles and permissions as well as how it
interacts with Laravel Policies. It will also serve as a guide to understand the use of Laravel Sanctum for API authentication.
Laravel - Permissions Spatie - Basic usage
Laravel Sanctum Documentation
Laravel 11.x Documentation - Authorization (Creating Policies)
Laravel Roles y Permisos con Spatie Permissions - Code with Luis
All tables before installing laravel-permissions
All tables after installing laravel-permissions
Diagram before installing laravel-permissions
Diagram after installing laravel-permissions
You can check query into /docs/query-examples-with-spatie.sql