Integrate into Laravel
Configuring Laravel to become multi tenant.
Service provider
The hyn packages are created to make it as easy as possible for you. Most functionality is added dynamically by hooking into the Laravel ecosystem. This unobtrusive behavior is initiated by registering the main service provider. Add the following under your providers array in config/app.php
.
/*
* Hyn packages
* @info FrameworkServiceProvider will load any available Service Provider from other hyn packages
*/
Hyn\Framework\FrameworkServiceProvider::class,
Please do not register the MultiTenantServiceProvider, this will break all functionality due to missing service providers of dependancies.
Third party eloquent models (optional)
To support multi tenancy in other packages and your own code, you'll have to make sure the eloquent models of this code uses the connection meant for the tenant or the system. In order to have all code use the tenant connection by default update the aliases
array in your app/config.php
by replacing the alias for Eloquent
.
'Eloquent' => Hyn\Tenancy\Abstracts\Models\TenantModel::class,
If instead you'd like to have all Eloquent models use the system connection by default just set the alias to the SystemModel
.
'Eloquent' => Hyn\Tenancy\Abstracts\Models\SystemModel::class,
Changing the alias while your application has several models in place, might have a serious impact. Please be aware that modifying the alias will result in all extended Models changing their connection too. Advice: on a new application pick one and stick to it, on an existing application keep the old alias and refactor your old Models to extend one of the abstract Models provided.
Updated less than a minute ago