healthCheck(); }); } public function healthCheck() { if ($this->database_type == 'mysql') { try { $connectionParams = [ 'user' => $this->username, 'password' => $this->password, 'host' => $this->host, 'port' => $this->port, 'driver' => 'pdo_mysql', ]; $connection = DriverManager::getConnection($connectionParams); $connection->connect(); if ($connection->isConnected()) { $this->status = 'online'; $this->save(); return; } } catch (\Exception $e) { $this->status = 'offline'; $this->save(); return; } } } }