Download the PHP package solutosoft/laravel-multitenant without Composer
On this page you can find all versions of the php package solutosoft/laravel-multitenant. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download solutosoft/laravel-multitenant
More information about solutosoft/laravel-multitenant
Files in solutosoft/laravel-multitenant
Package laravel-multitenant
Short Description The multi tenant control with shared table
License BSD-3-Clause
Homepage http://slto.com.br
Informations about the package laravel-multitenant
Laravel Multi Tenancy
The Shared Database used by all tenants, means that we keep data from all the tenants in the same database. To isolate tenant specific data, we will have to add a discriminator column like tenant_id
to every table which is tenant specific, and to make sure that all the queries and commands will filter the data based on it.
With this strategy dealing with tenant shared data is simple, we just don't filter it. Isolating data is what we need to deal with. For this we need to make sure that ALL the queries and the commands that deal with tenant specific data get filtered by the tenant_id
.
This extension allows control the Eloquent with shared database used by all tenants.
Installation
The preferred way to install this library is through composer.
Either run
composer require --prefer-dist solutosoft/laravel-multitenant "*"
or add
"solutosoft/laravel-multitenant": "*"
to the require section of your composer.json.
Usage
-
Create table with
tenant_id
column: - Uses the
MultiTenant
trait, it add a Global Scope filtering any query bytenant_id
column.
Now when you save or execute same query the tenant_id
column will be used. Example:
Auth Service Provider
It's necessary change the authentication service provider:
-
Creates new file:
app/Providers/TenantUserProvider.php
-
Edit
app/Providers/AuthServiceProvider.php
- Edit
config/auth.php
All versions of laravel-multitenant with dependencies
illuminate/database Version ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0
illuminate/events Version ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0