コード例 #1
0
 /**
  * Updates the settings.
  * Note that we have to create the parameter $id eventhough we won't use it:
  * The update method inherits from BackController->update($id).
  * We allow $id to be null so we do not have to pass an argument.
  * 
  * @param mixed $id Unused parameter
  */
 public function update($id = null)
 {
     if (!$this->checkAccessUpdate()) {
         return;
     }
     $settingsBag = new SettingsBag();
     $settingsBag->fill(Input::all());
     if (!$settingsBag->isValid()) {
         return Redirect::to('admin/config')->withInput()->withErrors($settingsBag->getErrors());
     }
     // Save the settings one by one:
     foreach ($settingsBag->getFillable() as $settingName) {
         $settingRealName = str_replace('app::', 'app.', $settingName);
         $result = DB::table('config')->whereName($settingRealName)->update(['value' => $settingsBag->{$settingName}, 'updated_at' => DB::raw('NOW()')]);
         /*
          * If the key does not exist we need to create it
          * $result contains the number of affected rows.
          * With using a timestamp we ensure that when updating a value
          * the row is always affacted, eventhough if the value does not change.
          */
         if ($result == 0) {
             DB::table('config')->insert(array('name' => $settingRealName, 'value' => $settingsBag->{$settingName}, 'updated_at' => DB::raw('NOW()')));
         }
         Config::clearCache($settingRealName);
     }
     $this->alertFlash(trans('app.updated', [$this->controllerName]));
     return Redirect::to('admin/config');
 }
コード例 #2
0
 /**
  * Updates the settings.
  * Note that we have to create the parameter $id eventhough we won't use it:
  * The update method inherits from BackController->update($id).
  * We allow $id to be null so we do not have to pass an argument.
  * 
  * @param mixed $id Unused parameter
  */
 public function update($id = null)
 {
     if (!$this->checkAccessUpdate()) {
         return;
     }
     $settingsBag = new SettingsBag();
     $settingsBag->fill(Input::all());
     if (!$settingsBag->isValid()) {
         return Redirect::to('admin/config')->withInput()->withErrors($settingsBag->getErrors());
     }
     // Save the settings one by one:
     foreach ($settingsBag->getFillable() as $settingName) {
         $settingRealName = str_replace('app::', 'app.', $settingName);
         DB::table('config')->whereName($settingRealName)->update(['value' => $settingsBag->{$settingName}]);
     }
     $this->alertFlash(trans('app.updated', [$this->controller]));
     return Redirect::to('admin/config');
 }