mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
refactor database connection failed error message
This commit is contained in:
@ -33,10 +33,14 @@ class EnvironmentController extends Controller
|
||||
*/
|
||||
public function saveDatabaseEnvironment(DatabaseEnvironmentRequest $request)
|
||||
{
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
$results = $this->EnvironmentManager->saveDatabaseVariables($request);
|
||||
|
||||
if(array_key_exists("success", $results)) {
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('cache:clear');
|
||||
Artisan::call('storage:link');
|
||||
Artisan::call('key:generate --force');
|
||||
Artisan::call('migrate --seed --force');
|
||||
|
||||
@ -48,19 +48,21 @@ class EnvironmentManager
|
||||
'DB_USERNAME='.$request->database_username."\n".
|
||||
'DB_PASSWORD='.$request->database_password."\n\n";
|
||||
|
||||
if (! $this->checkDatabaseConnection($request)) {
|
||||
|
||||
return [
|
||||
'error' => $this->checkDatabaseConnection($request)
|
||||
];
|
||||
} else {
|
||||
if(\Schema::hasTable('users') ) {
|
||||
return [
|
||||
'error' => 'database_should_be_empty'
|
||||
];
|
||||
try {
|
||||
if ($this->checkDatabaseConnection($request)) {
|
||||
if(\Schema::hasTable('users') ) {
|
||||
return [
|
||||
'error' => 'database_should_be_empty'
|
||||
];
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'error' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
|
||||
file_put_contents($this->envPath, str_replace(
|
||||
@ -321,7 +323,7 @@ class EnvironmentManager
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
return $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user