當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。