Is there any way to force Eloquent models to re resolve the connection they were instantiated with?
Right now I have a method that changes the database connection in
In my case, I did not have a database config for each of my databases, since they are created dynamically. I used the following approach, just changing the table name to include the database name as well (This works for MySQL):
foreach ($array as $key => $value) {
$productRepo = new ProductRepository();
$productRepo->setTable($key . '_' . $database);
$products = $productRepo->all();
}