From 0e703d3c84f3304f6808b53633b98c488a400ab4 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Mon, 9 Aug 2021 19:20:30 +0200 Subject: [PATCH] Add artisan command to check db connection --- app/Console/Commands/CheckDbConnection.php | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 app/Console/Commands/CheckDbConnection.php diff --git a/app/Console/Commands/CheckDbConnection.php b/app/Console/Commands/CheckDbConnection.php new file mode 100644 index 00000000..d75bf37b --- /dev/null +++ b/app/Console/Commands/CheckDbConnection.php @@ -0,0 +1,52 @@ +line('This will return the name of the connected database, otherwise false'); + + try { + DB::connection()->getPDO(); + $this->line(DB::connection()->getDatabaseName()); + return 1; + } catch (\Exception $e) { + return 0; + } + } +} \ No newline at end of file