I have been building a web application that tracks statistics.
These statistics can range between different companies.
I decided to use a main database to house all of the l
Well, you can't actually use config for this.
Configuration values that are set at run-time are only set for the current request, and will not be carried over to subsequent requests.
Laravel documentation reference.
Workaround
As a hacky workaround, and if you are not willing to use your main database to store the company database connection data, you could use a custom configuration file that you could update on run-time.
This is very similar to how the original config file works and it should keep the data persistently. However you have to build a control mechanism around it to keep the entries unique and consistent:
Update Config on Runtime Persistently
You could also look for a package for this so you dont have to re-invent the wheel. Check laravel-config-writer (disclaimer: never personally used it).