Multi Tenant Laravel ACL is a simple Multi Database Multi Tenant - user, company_user, role, permission ACL for SaaS Applications in Laravel Framework. This package was based on the great package yajra\laravel-acl but is catered to Multi-Database Multi-Tenant SaaS applications.
Via Composer
$ composer require muhammadsaeedparacha/multi-tenant-laravel-acl
Paracha\Acl\AclServiceProvider::class
'canAtLeast' => \Paracha\Acl\Middleware\CanAtLeastMiddleware::class,
'permission' => \Paracha\Acl\Middleware\PermissionMiddleware::class,
'role' => \Paracha\Acl\Middleware\RoleMiddleware::class,
'tenantConnection' => \Paracha\Acl\Middleware\TenantConnectionMiddleware::class,
'checkPermission' => \Paracha\Acl\Middleware\CheckPermissionsMiddleware::class,
'checkModularPermission' => \Paracha\Acl\Middleware\CheckModularPermissionsMiddleware::class,
Note: Currently only Supports MySQL
'tenant' => [
'driver' => 'mysql',
'host' => '',
'port' => env('DB_PORT', '3306'),
'database' => '',
'username' => '',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
$ php artisan vendor:publish --tag=multi-tenant-laravel-acl
[v: Optional] Configure your Tenant Migrations Locations: in Config\Acl
. The array defines folders within Database\Migrations
'tenantMigrations' => ['/tenants']
php artisan migrate
use Paracha\Acl\Traits\AclUser;
class Company extends Model
{
use AclUser
}
Route::group(['middleware' => ['auth:api','tenantConnection']], function(){
Route::group(['middleware' => ['checkPermission']], function(){
// Regular Permissions like users.create, users.update, users.read, users.delete, users.report
Route::resource('/users', 'UsersController');
});
// Customer Permissions like users.custom, users.xyz
Route::post('/users/invite', 'UsersController@invite')->middleware('checkPermission:users.custom');
});
$company = Company::find(1);
$company->createTenantDatabase();
$company->migrateTenant();
This will create Database with name db_1 for Company ID 1 with username = 1, and password = 'password' (This is insecure and needs to be secured)
Documentation is not written yet and the documentation of yajra\laravel-acl can be used till then since this project was based on it.
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The Apache-2.0 License. Please see License File for more information.