当前位置: 首页>>代码示例>>PHP>>正文


PHP Setting::firstOrNew方法代码示例

本文整理汇总了PHP中Setting::firstOrNew方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::firstOrNew方法的具体用法?PHP Setting::firstOrNew怎么用?PHP Setting::firstOrNew使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Setting的用法示例。


在下文中一共展示了Setting::firstOrNew方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: makeUpdate

 public static function makeUpdate($setting, $value = '', $userId = '')
 {
     $model = Setting::firstOrNew(array('settings_name' => $setting));
     $model->settings_value = $value;
     $model->settings_updateby = $userId;
     $model->save();
 }
开发者ID:hotarucms,项目名称:hotarucms,代码行数:7,代码来源:Setting.php

示例2: set

 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();
 }
开发者ID:y0sh1,项目名称:logboek,代码行数:8,代码来源:Setting.php

示例3: scopeKey

 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);
 }
开发者ID:pombredanne,项目名称:licenser-7,代码行数:9,代码来源:Setting.php

示例4: settings_post

 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.']);
 }
开发者ID:pombredanne,项目名称:licenser-7,代码行数:21,代码来源:UserController.php

示例5: update

 /**
  * 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;
 }
开发者ID:subbly,项目名称:framework,代码行数:37,代码来源:StatsService.php


注:本文中的Setting::firstOrNew方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。