Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. public function checkDatabaseConnection(Request $request)
  2. {
  3. //update the config
  4. config(['database.connections.mysql' => [
  5. 'host' => $request->host,
  6. 'username' => $request->username,
  7. 'password' => $request->password
  8. ]]);
  9.  
  10. //Check the credentials by calling PDO
  11. try {
  12. DB::connection()->getPdo();
  13. } catch (Exception $e) {
  14. return redirect()->back()->withErrors(["connection" => "Could not connect to the database. Please check your input."]);
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement