Exemplo n.º 1
0
 public static function makeUpdate($setting, $value = '', $userId = '')
 {
     $model = Setting::firstOrNew(array('settings_name' => $setting));
     $model->settings_value = $value;
     $model->settings_updateby = $userId;
     $model->save();
 }
Exemplo n.º 2
0
 public static function set($key, $value)
 {
     $setting = Setting::firstOrNew(['key' => $key]);
     $setting->key = $key;
     $setting->value = $value;
     Cache::put($key, $value, self::$expireTime);
     return $setting->save();
 }
Exemplo n.º 3
0
 public function scopeKey($query, $key)
 {
     if (count(Setting::where('key', '=', $key)->get()) == 0) {
         $setting = Setting::firstOrNew(['key' => $key]);
         $setting->value = '';
         $setting->save();
     }
     return $query->where('key', '=', $key);
 }
Exemplo n.º 4
0
 public function settings_post()
 {
     $inputs = Input::all();
     if (Input::hasFile('plugin')) {
         $file = Input::file('plugin');
         $name = time() . '-' . Str::slug($file->getClientOriginalName()) . "." . $file->getClientOriginalExtension();
         $moved = $file->move(public_path() . '/uploads/plugins/', $name);
         $plugin = Setting::firstOrNew(['key' => 'plugin_zip']);
         $plugin->value = $name;
         $plugin->save();
         $pluginPath = Setting::firstOrNew(['key' => 'plugin_zip_path']);
         $pluginPath->value = public_path() . '/uploads/plugins/' . $name;
         $pluginPath->save();
     }
     foreach ($inputs as $key => $value) {
         $setting = Setting::firstOrNew(['key' => $key]);
         $setting->value = $value;
         $setting->save();
     }
     return Redirect::to('/settings')->with('alert', ['type' => 'success', 'message' => 'Configuración guardada.']);
 }
Exemplo n.º 5
0
 /**
  * Update a setting value.
  *
  * @param string $key   The setting key
  * @param mixed  $value The setting value
  *
  * @return boolean
  *
  * @throws \Subbly\Api\Service\Exception If the setting key does not exists
  * @throws \Subbly\Api\Service\Exception If the setting value has not the good format
  *
  * @api
  */
 public function update($key, $value)
 {
     if ($this->fireEvent('updating', array($key, $value)) === false) {
         return false;
     }
     if (!is_string($key) || !$this->has($key)) {
         throw new Exception(sprintf(Exception::STATS_KEY_NOT_EXISTS, $key));
     }
     $default = $this->defaults($key);
     if (isset($default['type']) && gettype($value) !== $default['type']) {
         throw new Exception(sprintf(Exception::STATS_VALUE_WRONG_TYPE, json_encode($value), $key, $default['type']));
     }
     $stats = $this->getCachedStats();
     // TODO identifier = PACKAGE_NAME.KEY_NAME
     // Example subbly.shop_name
     $setting = Setting::firstOrNew(array('identifier' => $key, 'plugin_identifier' => ''));
     $setting->value = $value;
     $setting->setCaller($this);
     $setting->save();
     $stats->offsetSet($key, $value);
     $this->setCachedStats($stats);
     $this->fireEvent('updated', array($key, $value));
     return true;
 }