本文整理汇总了PHP中app\Setting::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::findOrFail方法的具体用法?PHP Setting::findOrFail怎么用?PHP Setting::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Setting
的用法示例。
在下文中一共展示了Setting::findOrFail方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
// bind article
$router->model('article', 'App\\Article');
$router->bind('admin.article', function ($id) {
return \App\Article::findOrFail($id);
});
// bind category
$router->model('category', 'App\\Category');
$router->bind('admin.category', function ($id) {
return \App\Category::findOrFail($id);
});
// bind language
$router->model('language', 'App\\Language');
$router->bind('admin.language', function ($id) {
return \App\Language::findOrFail($id);
});
// bind language
$router->model('page', 'App\\Page');
$router->bind('admin.page', function ($id) {
return \App\Page::findOrFail($id);
});
// bind setting
$router->model('setting', 'App\\Setting');
$router->bind('admin.setting', function ($id) {
return \App\Setting::findOrFail($id);
});
// bind user
$router->model('user', 'App\\User');
$router->bind('admin.user', function ($id) {
return \App\User::findOrFail($id);
});
parent::boot($router);
}
示例2: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
$setting = Setting::findOrFail(1);
$nhservers = Nhserver::all();
return view('setting.index', array('setting' => $setting, 'nhservers' => $nhservers));
}
示例3: update
public function update(Requests\SettingRequest $request, $id)
{
$setting = Setting::findOrFail($id);
//$setting->fill(\Request::all());
//return ['ok'=>$setting->save()];
return ['ok' => $setting->update($request->all())];
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(SettingRequest $request, $id)
{
$setting = Setting::findOrFail($id);
$setting->update($request->all());
session()->flash('flash_message', 'Se han actualizado los datos del Blog');
return redirect('admin/settings?tab=blog');
}
示例5: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
$setting = Setting::findOrFail(1);
$nhservers = Nhserver::all();
$devices = EngineerDevice::groupBy("device_sn")->count('device_sn');
$locations = EngineerDevice::groupBy('location_name')->count('location_name');
$engineers = EngineerDevice::groupBy('engineer_name')->count('engineer_name');
return view('setting.index', array('setting' => $setting, 'nhservers' => $nhservers, 'devices' => $devices, 'locations' => $locations, 'engineers' => $engineers));
}
示例6: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$this->validate($request, ['company_name' => 'required', 'company_name_kh' => 'required', 'company_name_ch' => 'required', 'company_logo' => 'required', 'copyright' => 'required', 'copyright_kh' => 'required', 'copyright_ch' => 'required', 'company_information' => 'required', 'company_information_ch' => 'required', 'company_information_kh' => 'required', 'meta_title' => 'required', 'meta_content' => 'required', 'meta_description' => 'required', 'meta_keyword' => 'required', 'status' => 'required|numeric']);
$setting = Setting::findOrFail($id);
$setting->updatedBy()->associate(Auth::user());
/*$setting->thumb_image = $request->input('image');
$setting->thumb_image = str_replace('source','thumbs',$setting->thumb_image);*/
$setting->update($request->all());
Session::flash('flash_message', 'Setting successfully updated!');
return redirect()->back();
}
示例7: doUpdateSettings
public function doUpdateSettings(Request $request)
{
$ids = [];
foreach ($request->except('_token') as $key => $field) {
$tmp = explode("-", $key);
$setting_id = $tmp[1];
$ids[] = $setting_id;
$setting = Setting::findOrFail($setting_id);
$setting->updateValue($field);
}
if (Setting::where('type', 'checkbox')->count() > 0) {
foreach (Setting::where('type', 'checkbox')->get() as $setting) {
if (!in_array($setting->id, $ids)) {
$setting->updateValue(0);
}
}
}
return redirect()->back()->with('settings-saved', true);
}
示例8: getIndex
public function getIndex()
{
$Set = Setting::findOrFail(1);
return view('admin.pengaturan.index', ['Set' => $Set]);
}