trailblazersoftware/multi-tenant

A Laravel 5.5+ package to help manage multi-tenancy roles and permissions.

dev-master 2022-08-13 08:55 UTC

This package is auto-updated.

Last update: 2024-04-13 12:22:26 UTC


README

This Laravel 5.5+ package provides an implementation of roles and permissions in a multi-tenant application. It borrows a lot from Entrust. Although all the Entrust functionalities are not yet implemented here, the roadmap includes doing so. The intend is for Laravel Multi-Tenant Roles to provide the following improvement (over Entrust):

  • Multi-Tenancy "out of the box".

  • Localization. Being able to provide a display name and descriptions for a role or permission in whatever language your Laravel application supports.

Installation

To install, simply run the command below in your terminal.

composer require "trailblazersoftware/multi-tenant:dev-master"

Setup

Multi Tenant uses Laravel's Auto-Discovery feature to register its Service Provider, and allow you to run its migration and publish its config file.

Publish The Config File

Run the following artisan command:

php artisan vendor:publish --provider="Trailblazer\MultiTenant\MultiTenantServiceProvider"

Or, you can type even less by simply typing php artisan vendor:publish and selecting the number corresponding to Trailblazer\MultiTenant\MultiTenantServiceProvider

Update The Config File

After running the vendor:publish command, you'll see a new config file MultiTenant.php in your projects_root/config directory.

Config Key Default Description Required
'role' 'App\Models\Users\Role' The Role model Yes
'roles_table' 'roles' The table where role models are stored Yes
'users_table' 'users' The table where user models are stored Yes
'user_key' 'id' The primary key for the user model Yes
'role_user_table' 'role_user' The pivot table where users' roles are stored Yes
'role_user_table' 'role_user' The pivot table where users' roles are stored Yes
'permission' 'role_user' The pivot table where users' roles are stored Yes
# Work in progress