Configure the database and boot Eloquent

@param array $configs null
@param string $name default
@param bool $enableQueryLog true
@return mixed
351651
public function dbConnection(array $configs = null, $name = 'default', $enableQueryLog = true)
	{
		$db = new DB();

		$db->addConnection(($configs) ? $configs : $this->config('db'), $name);
        $db->setEventDispatcher(new Dispatcher(new Container));
		$db->setAsGlobal();
		$db->bootEloquent();

        if ($enableQueryLog)
        {
            DB::connection()->enableQueryLog();
        }

        $this->db = $db;

        return $db;
	}
157147
protected static function getRepositoryByConfig($config, $name)
    {
        if (!is_array($config)) {
            if (class_exists($config)) {
                return new $config;
            }

            throw new Exception('Cannot create repository from string');
        } elseif ($config['driver'] == 'faker') {
            return new Faker(Factory::create());
        } elseif ($config['driver'] == 'middleware') {
            return resolve($config['middleware'])->execute(function() {
            }
            );
        }

        return static::initPdoDatabase($config, $name);
    }
1135487
public static function get($name, $config = NULL)
    {
        if(isset($_COOKIE[$name]))
        {
            // Decrypt cookie using cookie key
            if($v = json_decode(Cipher::decrypt(base64_decode($_COOKIE[$name]), Config::config()->key), true))
            {
                return $v;
            }
        }

        return FALSE;
    }
2919
public function loadConfigs(...$names)
    {
        /** @var Config $config */
        $config = $this->make(Config::class);
        foreach ($names as $name) {
            $config->load($name);
        }
    }
597765
public function find($name, $fields = [])
    {
        $namingContext = $this->getConfigurationNamingContext();

        if ($namingContext) {
            return $this->adldap->search()
                ->setDn($namingContext)
                ->select($fields)
                ->where('objectCategory', '=', $this->serverObjectCategory)
                ->where('anr', '=', $name)
                ->first();
        }

        return false;
    }
204063
public static function detect(string $namespace, string $configPath, string $name = null, bool $strict = true) : array
    {
        $configName = null;
        $method = $strict ? 'get' : 'getIfExists';

        if (is_null($name)) {
            $configName = 'default';
        } elseif (class_exists($name)) {
            $all = self::config()->$method($configPath);
            foreach ($all ?? [] as $key => $value) {
                if (stripos($name, $key) === 0) {
                    $configName = $key;
                    break;
                }
            }
        } elseif (is_string($name)) {
            $configName = $name;
        }

        if (is_null($configName)) {
            if ($strict) {
                throw new \RuntimeException(sprintf(
                    "Can't detect configuration for namespace: '%s', config: '%s', type: '%s'",
                    $namespace,
                    $configPath,
                    is_string($name) ? $name : get_class($name)
                ));
            } else {
                $configName = 'default';
            }
        }

        if ($strict == false && is_null($configName)) {
            if ($return = self::get($namespace, $name)) {
                return [null, null, $return];
            }

            return [$name, null, $return];
        }

        if ($return = self::get($namespace, $configName)) {
            return [null, null, $return];
        }

        $config = self::config()->$method($configPath . '/' . $configName);

        if ($config) {
            return [$configName, $config, null];
        } elseif ($strict == false) {
            return [$configName ?: $name, null, null];
        }
    }
899258
static function enable(string $name) {
        if (!isset(self::$_captchaList[$name])) {
            Console::warning("Captcha generator \"$name\" do not exist.");
            return;
        }
        self::$_enableList = self::$_enableList + [$name];
    }
730441
static public function cache($name=null)
	{
	    $id = 'cache' . ( isset($name) ? '.'.$name : '' );
	    if (!static::has($id)) {
	        static::setShared($id, function () use ($name) {
	            // common config
	            $options = Config::getCommon('cache') ?: [];
	            
	            // compoment level config
	            if ($name) {
	                if ($name == 'db') $name = 'database';
	                
	                $m_options = Config::getByType('cache', $name);
	                if (!isset($m_options['path']) && !isset($m_options['group'])) {
	                    $options['group'] = $name;
	                }
	                if ($m_options) {
	                    $options = ArrayHelper::merge($options, $m_options);
	                }
	            }
	            
	            $options['path'] = isset($options['path']) ? ltrim($options['path'], '/') : 'caches';
	            $options['path'] = Config::getStoragePath() . $options['path'];
	            return new Cache($options);
	        });
	    }
	    return static::get($id);
	}
1002811
public function configure($name)
    {
        if (isset($this->loadedConfigurations[$name])) {
            return;
        }

        $this->loadedConfigurations[$name] = true;

        $path = $this->getConfigurationPath($name);

        if (! \is_null($path)) {
            $this->make('config')->set(Arr::dot([
                $name => require $path,
            ]));
        }
    }
876024
public static function make($name='default') {
		$configs = static::listConfig();
		
		if( !isset($configs[$name]) ) {
			throw new SQLException('Database configuration with name "'.$name.'" not found.', 'Loading configuration');
		}
		
		$config = $configs[$name];
		
		if( empty($config['driver']) ) {
			throw new SQLException('Database configuration with name "'.$name.'" has no driver property.', 'Loading configuration');
		}
		
		if( empty(static::$adapters[$config['driver']]) ) {
			throw new SQLException('Database configuration with name "'.$name.'" requires an unknown driver "'.$config['driver'].'".', 'Loading configuration');
		}
		
		$adapterClass = static::$adapters[$config['driver']];
		return new $adapterClass($name, $config);
		
	}
729762
public function get_config($name)
	{
		return isset($this->config[$name]) ? $this->config[$name] : null;
	}
1289910
public function setDisabled($name)
    {
        $this->checkIfSnippetExists($name);
        $this->snippets[$name]['enabled'] = false;
        return $this;
    }
952630
public static function cfg($name = '@default', $default = '') {
        $app  = self::$app;
        $keys = null;
        if ($name != null) {
            $names = explode('@', $name);
            if ($names[0]) {
                $name = $names[0];
                $keys = explode('.', $name);
                $name = array_shift($keys);
            } else {
                $name = null;
            }
            if (isset($names[1]) && $names[1]) {
                $config = $names[1];
            } else {
                $config = 'default';
            }
        } else {
            $config = 'default';
        }
        if (isset ($app->configs [ $config ])) {
            $confObj = $app->configs [ $config ];
        } else {
            $confObj = $app->configLoader->loadConfig($config);
            if (!$confObj) {
                $confObj = new Configuration ($config);
            }
            $app->configs [ $config ] = $confObj;
        }

        if ($name == null) {
            return $confObj;
        } else {
            $values = $confObj->get($name, $default);
            if ($keys && is_array($values)) {
                foreach ($keys as $ky) {
                    if (isset($values[ $ky ])) {
                        $values = $values[ $ky ];
                    }
                }
            }

            return $values;
        }
    }
1270383
protected function doSelectDatabase($name)
    {
        $mongoDB = $this->mongoClient->selectDB($name);
        $numRetries = $this->config->getRetryQuery();
        $loggerCallable = $this->config->getLoggerCallable();

        return $loggerCallable !== null
            ? new LoggableDatabase($this, $mongoDB, $this->eventManager, $numRetries, $loggerCallable)
            : new Database($this, $mongoDB, $this->eventManager, $numRetries);
    }
337057
public function getItemConfig($name = null, array $config = [])
    {
        return array_merge([
            'domain' => $name,
            'nginx'  => $this,
            'class'  => $this->defaultClass,
        ], $config);
    }
228366
public function make($config, $name = null)
    {
        $config = $this->parseConfig($config, $name);

//        if (isset($config['read'])) {
//            return $this->createReadWriteConnection($config);
//        }
        return $this->createSingleConnection($config);
    }
203703
public static function create(array $config, $name = 'default')
    {
        // Make sure a connection with same name doesn't exist
        if (array_key_exists($name, static::$connections)) {
            throw new Exception("Database connection {$name} already exists.");
        }

        // Set the class name, with the namespace
        $className = '\Radium\Database\\'. $config['driver'];

        // Connect to the database and return the object
        static::$connections[$name] = new $className($config, $name);
        return static::$connections[$name];
    }