1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 20:54:03 +00:00

tenant specific config

This commit is contained in:
Samuel Štancl 2019-08-20 11:45:19 +02:00
parent 973b777d04
commit 6737172589

View file

@ -17,7 +17,7 @@ The following events are available:
You can hook into these events using `Tenancy::<eventName>`: You can hook into these events using `Tenancy::<eventName>`:
```php ```php
Tenancy::boostrapping(function ($tenantManager) { \Tenancy::boostrapping(function ($tenantManager) {
if ($tenantManager->tenant['uuid'] === 'someUUID') { if ($tenantManager->tenant['uuid'] === 'someUUID') {
config(['database.connections.someDatabaseConnection' => $tenantManager->tenant['databaseConnection']]); config(['database.connections.someDatabaseConnection' => $tenantManager->tenant['databaseConnection']]);
$tenantManager->database->useConnection('someDatabaseConnection'); $tenantManager->database->useConnection('someDatabaseConnection');
@ -33,4 +33,11 @@ The following actions can be prevented:
- database connection switch: `database` - database connection switch: `database`
- Redis prefix: `redis` - Redis prefix: `redis`
- CacheManager switch: `cache` - CacheManager switch: `cache`
- Filesystem changes: `filesystem` - Filesystem changes: `filesystem`
Another common use case for events is tenant-specific config:
```php
\Tenancy::bootstrapped(function ($tenantManager) {
config(['some.api.key' => $tenantManager->tenant['api_key']);
});
```