command to check if connection is made to databse
tayyabbashir2224 opened this issue · 0 comments
tayyabbashir2224 commented
i want to create a command to check if it is connected to database here is my code but not working that way
`<?php
namespace App\Telegram\Commands;
use Telegram\Bot\Commands\Command;
use Telegram;
class DatabaseStatusCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'chkdb';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$connectionParams = [
'host' => env('DB_HOST'),
'port' => env('DB_PORT'),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
];
DB::connection($connectionParams)->table('my_table')->get();
}
}
`