/**
  * Load the configuration items from the database.
  *
  * @param  RepositoryContract  $config
  * @return void
  */
 protected function loadConfigurationDatabase(RepositoryContract $config)
 {
     // Bootstrap the Repository class
     $siteConfigRepository = new ConfigLoaderRepository();
     // Load the configuration into the current running config.
     $siteConfigRepository->setRunningConfiguration($config);
 }
 /**
  * Set a given configuration value and store it in the database.
  *
  * This stores a configuration value with a key => value pair into
  * the database against a specific environment and website_id (which
  * default to NULL).
  *
  * The key is represented as group.key for simple key=>value pairs within
  * group "group" or group.key1.key2.key3 ... for nested keys, stored as
  * arrays within the global configuration.
  *
  * @param  string      $key
  * @param  mixed       $value
  * @param  null|string $environment
  * @param  null|integer $website_id
  * @return void
  */
 public function set($key, $value, $environment = null, $website_id = null)
 {
     // Bootstrap the ConfigLoaderRepository class
     $siteConfigRepository = new ConfigLoaderRepository();
     // Parse the key here into group.key.part components.
     //
     // Any time a . is present in the key we are going to assume the first section
     // is the group.  If there is no group present then we assume that the group
     // is "config".
     $explodedOnGroup = explode('.', $key);
     if (count($explodedOnGroup) > 1) {
         $group = array_shift($explodedOnGroup);
         $item = implode('.', $explodedOnGroup);
     } else {
         $group = 'config';
         $item = $key;
     }
     // What type is the value we are setting?
     if (is_array($value)) {
         $type = 'array';
     } elseif (is_int($value)) {
         $type = 'integer';
     } else {
         $type = 'string';
     }
     // Now we have the group / item as separate values, we can store these
     ConfigModel::set($item, $value, $group, $environment, $website_id, $type);
     // Flush the cache
     $siteConfigRepository->forgetConfig();
     // Reload the config
     $siteConfigRepository->loadConfiguration();
     // Fetch the configuration that has already been loaded.
     $config = config();
     // Store it into the running config
     $siteConfigRepository->setRunningConfiguration($config);
 }