manual mode blade

This commit is contained in:
Samuel Štancl 2020-06-15 12:46:23 +02:00
parent 5c5af86851
commit 91badf2929

View file

@ -0,0 +1,27 @@
---
title: Manual tenancy mode
extends: _layouts.documentation
section: content
---
# Manual mode
> See: [Automatic mode]({{ $page->link('automatic-mode') }})
If you wish to use the package only to keep track of the current tenant and make the application tenant-aware manually — without the use [Tenancy bootstrappers]({{ $page->link('tenancy-bootstrappers') }}), you can absolutely do that.
You may use the `Stancl\Tenancy\Database\Concerns\CentralConnection` and `Stancl\Tenancy\Database\Concerns\TenantConnection` model traits to make models explicitly use the given connections.
To create the tenant connection, set up the `CreateTenantConnection` listener:
```php
// app/Providers/TenancyServiceProvider.php
Events\TenancyInitialized::class => [
Listeners\CreateTenantConnection::class,
],
```
This approach is generally discouraged, because you lose all of the benefits of the [automatic mode]({{ $page->link('automatic-mode') }}), but **there won't be any issues with the package** if you decide to use the manual mode. You might not be able to integrate other packages as easily, but if for whatever reason it makes more sense for your project to use this approach, feel comfortable to do so.