本文整理汇总了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']);
}
示例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');
}
}