public function saveDatabase($default, $host, $name, $username, $password)
{
$settings = ['DB_DEFAULT' => $default, 'DB_HOST' => $host, 'DB_DATABASE' => $name, 'DB_USERNAME' => $username, 'DB_PASSWORD' => $password];
// no errors at the moment
$this->errors = null;
// we will write out to the database config file one time only
$this->DeviseInstallCommand->changeDatabaseConfigFile();
// check to see if this is valid database settings or not
if ($this->isValidDatabaseSettings($settings)) {
return $this->EnvironmentFileManager->merge($settings);
}
// attempt to create the database and then try again
if ($this->createDatabaseWithSettings($settings)) {
return $this->EnvironmentFileManager->merge($settings);
}
// well... something screwed up so we need to tell the user about it
$this->errors = new MessageBag(['database' => 'Invalid database settings, could not connect to this database with given username and password!']);
}