From 1683da7cf3ef74cac4f45b78bf8b0861c5a3ca33 Mon Sep 17 00:00:00 2001 From: Timoffei Bubigo Date: Wed, 27 Jan 2021 12:46:19 +0300 Subject: [PATCH] Read all database settings --- app/Console/Commands/HRCCommand.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Console/Commands/HRCCommand.php b/app/Console/Commands/HRCCommand.php index fc9a953..b1bfadc 100644 --- a/app/Console/Commands/HRCCommand.php +++ b/app/Console/Commands/HRCCommand.php @@ -58,11 +58,21 @@ class HRCCommand extends Command file_put_contents($result_file, json_encode($result)); } + private function getCoreConfig($name) + { + $config = parse_ini_file(mb_strtolower(file_get_contents(CORE_PATH . '/../../db.ini'))); + return $config[$name]; + } + public function initDB() { $code = $this->option('unn'); DB::disconnect('mysql'); + Config::set('database.connections.mysql.username', $this->getCoreConfig('user')); + Config::set('database.connections.mysql.password', $this->getCoreConfig('password')); + Config::set('database.connections.mysql.host', $this->getCoreConfig('server')); + Config::set('database.connections.mysql.port', $this->getCoreConfig('port')); Config::set('database.connections.mysql.database', $code); DB::reconnect(); }