public function resetTestData()
 {
     DB::statement('truncate table dbconfig_settings');
     DBConfig::Create(array('group' => 'auth', 'key' => 'model', 'value' => 'User', 'type' => 'string'));
     DBConfig::Create(array('group' => 'auth', 'key' => 'model', 'value' => 'Dev User', 'type' => 'string', 'environment' => 'development'));
     DBConfig::Create(array('package' => 'alpha', 'group' => 'config', 'key' => 'title', 'value' => 'Alpha Title', 'type' => 'string'));
     DBConfig::Create(array('package' => 'beta', 'group' => 'maps', 'key' => 'nz', 'value' => 'New Zealand', 'type' => 'string'));
     DBConfig::Create(array('package' => 'beta', 'group' => 'maps', 'key' => 'nz', 'value' => 'New Z-dev', 'type' => 'string', 'environment' => 'development'));
     DBConfig::Create(array('package' => 'charlie', 'group' => 'config', 'key' => 'first', 'value' => 'Charlie is First!', 'type' => 'string'));
     DBConfig::Create(array('package' => 'charlie', 'group' => 'config', 'key' => 'finger', 'value' => 'Charlie bit my finger!', 'type' => 'string'));
     DBConfig::Create(array('package' => 'charlie', 'group' => 'config', 'key' => 'last', 'value' => 'Charlie is Last!', 'type' => 'string'));
     DBConfig::Create(array('package' => 'delta', 'group' => 'group', 'key' => 'arr', 'value' => serialize(array('foo' => 'bar')), 'type' => 'array'));
 }
 public static function set($value, $package, $group, $key, $environment, $type)
 {
     //Lets check if we are doing special array handling
     $arrayHandling = false;
     $keyExploded = explode('.', $key);
     if (count($keyExploded) > 1) {
         $arrayHandling = true;
         $key = array_shift($keyExploded);
         if ($type == 'array') {
             $value = unserialize($value);
         }
     }
     // First let's try to fetch the model, if it exists then we need to do an
     // Update not an insert
     $model = DatabaseConfigLoaderModel::where('key', $key)->where('group', $group);
     is_null($environment) ? $model->whereNull('environment') : $model->where('environment', $environment);
     is_null($package) ? $model->whereNull('package') : $model->where('package', $package);
     $model = $model->first();
     if (is_null($model)) {
         //Check if we need to do special array handling
         if ($arrayHandling) {
             // we are setting a subset of an array
             $array = array();
             self::buildArrayPath($keyExploded, $value, $array);
             $value = serialize($array);
             $type = 'array';
         }
         DatabaseConfigLoaderModel::create(array('environment' => $environment, 'package' => $package, 'group' => $group, 'key' => $key, 'value' => $value, 'type' => $type));
     } else {
         //Check if we need to do special array handling
         if ($arrayHandling) {
             // we are setting a subset of an array
             $array = array();
             self::buildArrayPath($keyExploded, $value, $array);
             //do we need to merge?
             if ($model->type == 'array') {
                 $array = array_replace_recursive(unserialize($model->value), $array);
             }
             $value = serialize($array);
             $type = 'array';
         }
         $model->value = $value;
         $model->type = $type;
         $model->save();
     }
 }
 public function set($value, $package, $group, $item, $environment)
 {
     unset($this->exists[$group . $package]);
     $type = null;
     $givenType = strtolower(gettype($value));
     switch ($givenType) {
         case 'string':
         case 'integer':
         case 'double':
         case 'boolean':
         case 'null':
             $type = $givenType;
             break;
         case 'array':
             $value = serialize($value);
             $type = 'array';
             break;
         default:
             $type = null;
     }
     $this->model->set($value, $package, $group, $item, $environment, $type);
 }