Skip to content

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.

Notifications You must be signed in to change notification settings

abrahamuchos/roles-with-spatie-permissions

Repository files navigation

Laravel Roles and Permissions with Spatie

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.

✅ Features

  • Roles and Permissions
  • Authentication
  • Authorization
  • Policies
  • Gates
  • Seeder
  • Factory
  • Migrations
  • Controllers
  • Tests
  • Routes

⚙️ Tech Stack

  • Laravel 11
  • Postgres 14
  • Spatie Laravel-Permission 6.10
  • Laravel Sanctum 4.0

💾 Installation

Install and run

  1. Clone and move to folder
$ git clone [email protected]:abrahamuchos/roles-with-spatie-permissions.git
$ cd roles-with-spatie-permissions
  1. Install dependencies
$  composer install
  1. Create a copy of the .env.example file and rename it to .env. Next, configure the necessary environment variables.

  2. Generate an application key by running php artisan key:generate.

  3. Run php artisan migrate to create the database tables.

  4. Run php artisandb:seed to create dummy data and admin user.

  5. Run php artisan serve to start the Laravel development server.

  6. Run php artisan test to run the tests.

📦 Environment Variables

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

🗂️ Docs

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

Some observations on the database.

All tables before installing laravel-permissions

screen-landing-page

All tables after installing laravel-permissions

screen-landing-page

Diagram before installing laravel-permissions

screen-landing-page


Diagram after installing laravel-permissions

screen-landing-page

You can check query into /docs/query-examples-with-spatie.sql

🧑‍💻 Authors

📄 License

MIT

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages