Downloads
Stars
Version
This package is intended to be a flexible starting point for new multi-tenant projects in Laravel. Still a WIP
You can install the package via composer:
composer require mymediamagnet/multi-tenant-laravel
php artisan vendor:publish
and selecting multi-tenant-laravel as the packagephp artisan migrate
. This will create all the tables required in this packageapp\Http\Middleware\RedirectIfAuthenticated
you might see return redirect('/home');
. Change this to return redirect('/');
.Create the following models for the primary tables in the packages migrations. Make sure to extend the base classes from the package
use MultiTenantLaravel\App\Models\BaseUser;
class User extends BaseUser
{
...
}
use MultiTenantLaravel\App\Models\BaseTenant;
class Tenant extends BaseTenant
{
...
}
Follow the same pattern in making your Role, Permission & Feature models
By default your project should now be setup to automatically redirect you to the login page on visit. To create a new user, you can use the helper command.
php artisan tenant:create-user
- you will be asked a series of questions to setup your new user, or you can quickly create a fake user using php artisan tenant:create-user --fake
To create a new tenant:
php artisan tenant:create-tenant
- you will be asked a series of questions to setup your new tenant, or you can quickly create a fake tenant using php artisan tenant:create-tenant --fake
When creating a new tenant, you will be provided the option to add an existing user to the tenant, or create a new user.
Once you login, if your user is only a member of 1 tenant you will be immediatly redirected to that tenants dashboard. Otherwise, you'll land on a dashboard that allows you to select which dashboard you would like to manage
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.