setup using different config values for different tenants when using multiple databases per tenant #636
MattWiseParking
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have figured away to create different config values for each tenant when using a multiple database setup per tenant.
Here is the process:
The config_group represents the config file, the config_key represents the array within (you use dot notation for a specific array value for nested arrays), and the config_value represents the value you want to change against the key.
Run
php artisan tenants:artisan "migrate"As you can see it uses cache to cache the original data, then stores the config cache, so instead if reading the table every request, it checks the cache first, if exists then uses that. this essentially saves thousdands of un necessary requests being sent to the database server.
You will of course need to create your own CRUD against the table. It now means that you can interact with stripe and use different API keys for different tenants, plus change the config for each tenant. When you do create your own CRUD using a Config model, ensure that you create an observer ConfigObserver then create the link in the EventServiceProvider. Most importantly you will need to clear the cache after every change/update/delete.
Here is a copy of the observer:
Hope you like this :)
Beta Was this translation helpful? Give feedback.
All reactions