Я нашел решение. Поделись ею со всеми:)
Сначала сделай Connection
модель.
Затем добавь код в app/Providers/AppServiceProvider.php
//connections
if (\Schema::hasTable('connections')) {
$connections = \App\Models\Connection::all();
$db = \Config::get('database.connections');
foreach ($connections as $connection)
{
$db['cdb_'.$connection->id] = [
'driver' => 'mysql',
'host' => $connection->db_host,
'port' => $connection->db_port,
'database' => $connection->db_database,
'username' => $connection->db_user,
'password' => $connection->db_pass,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci', //utf8_unicode_ci
'prefix' => '',
'strict' => false,
];
}
\Config::set('database.connections',$db);
}else{
\Config::set('database.connections',[]);
}
Schema::defaultStringLength(191);