mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 18:24:03 +00:00
2.x filesystem tenancy, events
This commit is contained in:
parent
71287b36cb
commit
3a131a3202
2 changed files with 15 additions and 13 deletions
|
|
@ -17,9 +17,9 @@ The following events are available:
|
|||
|
||||
### Tenant-specific database connection example {#tenant-specific-database-connection-example}
|
||||
|
||||
You can hook into these events using `Tenancy::<eventName>`:
|
||||
You can hook into these events using `Tenancy::eventListener(<eventName>, function () {})`:
|
||||
```php
|
||||
\Tenancy::boostrapping(function ($tenantManager) {
|
||||
\Tenancy::eventListener('bootstrapping', function ($tenantManager) {
|
||||
if ($tenantManager->tenant['id'] === 'someID') {
|
||||
config(['database.connections.someDatabaseConnection' => $tenantManager->tenant['databaseConnection']]);
|
||||
$tenantManager->database->useConnection('someDatabaseConnection');
|
||||
|
|
@ -41,7 +41,7 @@ The following actions can be prevented:
|
|||
|
||||
Another common use case for events is tenant-specific config:
|
||||
```php
|
||||
\Tenancy::bootstrapped(function ($tenantManager) {
|
||||
\Tenancy::eventListener('bootstrapped', function ($tenantManager) {
|
||||
config(['some.api.key' => $tenantManager->tenant['api_key']);
|
||||
});
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue