Skip to content

Instantly share code, notes, and snippets.

@acacha
Created June 20, 2017 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acacha/17201587a98ce1910707cd29ff5d2f10 to your computer and use it in GitHub Desktop.
Save acacha/17201587a98ce1910707cd29ff5d2f10 to your computer and use it in GitHub Desktop.
A helper for checking connection on Laravel.
if (!function_exists('check_connection')) {
/**
* Check database connection.
*
* @param $connection
* @return bool
*/
function check_connection($connection)
{
try {
app()->make('db')->connection($connection)->getPdo();
} catch (\Exception $e) {
return false;
}
return true;
}
}
@acacha
Copy link
Author

acacha commented Jun 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment