public function update() { if (!$this->app['sentry']->getUser()->hasAccess('superuser')) { return new Response($this->app['translator']->trans('noPermissionsGeneric'), 403); } foreach ($this->input->all() as $name => $value) { $option = $this->setting->where('name', $name)->first(); if ($option) { $this->setting->where('name', $name)->update(array('value' => $value)); } else { $this->setting->insert(array('name' => $name, 'value' => $value)); } } return new Response($this->app['translator']->trans('settingsUpdated'), 201); }
public function seedSettings() { try { SettingModel::insert(array(array('name' => 'enable_registration', 'value' => 1), array('name' => 'update_version', 'value' => $this->app['version']), array('name' => 'permissions', 'value' => '{"templates.delete":1,"templates.update":1,"templates.create":1,"users.delete":0,"users.update":0,"export":1,"publish":1,"projects.create":1,"projects.update":1,"projects.delete":1,"themes.create":1,"themes.update":1,"themes.delete":1,"users.create":0}'))); } catch (\Exception $e) { // } }
public function runUpdate() { if (Capsule::schema()->hasTable('settings')) { $updateVersion = SettingModel::where('name', 'update_version')->first(); if ($updateVersion && $updateVersion->value == $this->app['version']) { return $this->app->redirect('/'); } } $s = new Seeder($this->app, $this->app['projects.creator']); $s->seedTemplates(); $s->seedLibraries(); if (SettingModel::where('name', 'update_version')->first()) { SettingModel::where('name', 'update_version')->update(array('value' => $this->app['version'])); } else { SettingModel::insert(array('name' => 'update_version', 'value' => $this->app['version'])); } return $this->app->redirect('/'); }