A full-featured multi-tenant app with Laravel Part 2 — Roles and Permissions

Ashok Gelal
4 min readDec 17, 2017
Photo by Michael Mroczek

Part 0, Part 1, Part 2 👇, Part3, Part4, Part 5, Part 6, Part 7

In this part of writing a complete Laravel multi-tenant app series, we’ll accomplish the following tasks:

✅ Install and configure a package for managing roles and permissions

✅ Seed the database with some roles and permissions

✅ Give all the power needed for an admin user to administer the new tenant

1. Install and configure a package for managing roles and permissions

We’ll use spatie’s excellent laravel-permission package for managing roles and permissions in our multi-tenant app (MTA). Go and read the documentation first. You don’t need to understand everything right now but just be familiar with some of the concepts and commands.

Once you are done, add the package:

composer require spatie/laravel-permission

Now, we have to make this package aware of multi-tenancy setup by setting proper connection name to the package’s core Eloquent models —Permission and Role.

We obviously don’t want to change these models in the vendor directory to make them multi-tenancy aware. We have to…

--

--

Ashok Gelal

Learner. Achiever. Loves writing clean code and craft beautiful products. 👉 https://alpas.dev