當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Setting::firstOrCreate方法代碼示例

本文整理匯總了PHP中app\Setting::firstOrCreate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Setting::firstOrCreate方法的具體用法?PHP Setting::firstOrCreate怎麽用?PHP Setting::firstOrCreate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Setting的用法示例。


在下文中一共展示了Setting::firstOrCreate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Setting::firstOrCreate(['name' => 'is_installed', 'setting' => 'yes']);
     Setting::firstOrCreate(['name' => 'is_installed', 'setting' => 'no']);
     Setting::firstOrCreate(['name' => 'default_profile_picture', 'setting' => '/images/default_profile_image.png']);
     Setting::firstOrCreate(['name' => 'company_name', 'setting' => 'Genesis Events Ltd.']);
     Setting::firstOrCreate(['name' => 'description', 'setting' => 'We are an awesome company']);
     Setting::firstOrCreate(['name' => 'company_logo', 'setting' => '/images/logo_full.png']);
     Setting::firstOrCreate(['name' => 'company_logo_white', 'setting' => '/images/logo_full_white.png']);
 }
開發者ID:TheJokersThief,項目名稱:Eve,代碼行數:15,代碼來源:SettingsSeeder.php

示例2: update

 public function update()
 {
     $validator = Validator::make(['source_template' => Input::get('source_template')], ['source_template' => 'required']);
     if ($validator->fails()) {
         // send back to the page with the input data and errors
         return Redirect::to('sourceTemplate')->withInput()->withErrors($validator);
     } else {
         //store into db
         $sourceTemplate = Setting::firstOrCreate(['meta_name' => 'sourceTemplate'])->first();
         $sourceTemplate->meta_name = 'sourceTemplate';
         $sourceTemplate->meta_value = Input::input('source_template');
         $sourceTemplate->save();
         return redirect()->route('sourceTemplate')->with('message', 'Source template updated.')->with('message-class', 'success');
     }
 }
開發者ID:mispy,項目名稱:our-world-in-data-grapher,代碼行數:15,代碼來源:SourceTemplateController.php


注:本文中的app\Setting::firstOrCreate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。