diff --git a/app/Console/Commands/HRCCommand.php b/app/Console/Commands/HRCCommand.php index 63414be..9519dc8 100644 --- a/app/Console/Commands/HRCCommand.php +++ b/app/Console/Commands/HRCCommand.php @@ -58,15 +58,12 @@ class HRCCommand extends Command file_put_contents($result_file, json_encode($result)); } - private function getCoreConfig($name) + private function getCoreConfig($name, $default = null) { $config = parse_ini_file(CORE_PATH . '/../../db.ini'); + $config = array_change_key_case($config); - $config = array_map(function($value) { - return mb_strtolower($value); - }, $config); - - return $config[$name]; + return $config[$name] ?? $default; } public function initDB() @@ -74,10 +71,10 @@ class HRCCommand extends Command $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.username', $this->getCoreConfig('user', 'hrc')); + Config::set('database.connections.mysql.password', $this->getCoreConfig('password', 'hrc.lan')); + Config::set('database.connections.mysql.host', $this->getCoreConfig('server', '127.0.0.1')); + Config::set('database.connections.mysql.port', $this->getCoreConfig('port', '3306')); Config::set('database.connections.mysql.database', $code); DB::reconnect(); } diff --git a/composer.json b/composer.json index 65d1251..926c39e 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "license": "MIT", "type": "project", "require": { - "php": "^7.3|^8.0", + "php": "7.0", "laravel/lumen-framework": "^8.0", "ext-json": "*" },