I have an issue where I am struggling to set the database connection for a database seeder. I am trying to set the config for the updated DB details, however when I call the migrate artisan command, it gets the existing connection details from the config/database.php and then seeds the wrong database.
Why is Config::set not overwriting the connection details?
My seeder:
public function run(){ $databases = SchoolDatabase::all(); foreach ($databases as $db) { Config::set('database.connections.school', ['driver' => 'mysql','host' => $db->host,'port' => $db->port,'database' => $db->database_name,'username' => $db->database_username,'password' => $db->database_password, ]); Artisan::call('db:seed', ['--database' => 'school','--class' => 'SchoolStudentSeeder' ] ); }}