Package Data | |
---|---|
Maintainer Username: | muhammadsaeedparacha |
Maintainer Contact: | saeedparacha13@gmail.com (Muhammad Saeed Paracha) |
Package Create Date: | 2017-08-10 |
Package Last Update: | 2017-11-29 |
Home Page: | |
Language: | PHP |
License: | Apache-2.0 |
Last Refreshed: | 2024-11-15 15:06:28 |
Package Statistics | |
---|---|
Total Downloads: | 50 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 0 |
Total Forks: | 0 |
Total Open Issues: | 0 |
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,
Config\Database
to be filled on the fly based on tenant: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
Config\Acl
. The array defines folders within Database\Migrations
'tenantMigrations' => ['/tenants']
php artisan migrate
App\User
Model:use Paracha\Acl\Traits\AclUser;
class Company extends Model
{
use AclUser
}
routes\api.php
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');
});
config('acl.tenantMigrations')
$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 saeedparacha13@gmail.com instead of using the issue tracker.
The Apache-2.0 License. Please see License File for more information.