/** * Update the specified settings in storage. * @param UpdateSettingsRequest|Request $request * * @param int $id */ public function update($id, UpdateSettingsRequest $request) { $settings = Settings::findOrFail($id); $request = $this->saveFiles($request); $settings->update($request->all()); return redirect()->route('admin.settings.index'); }
public function edit(Request $request) { $id = 0; if (isset($request->id)) { $id = $request->id; } $modelData = new \stdClass(); if ($id > 0) { try { $modelData = Settings::findOrFail($id); } catch (ModelNotFoundException $e) { session()->flash('message', trans('admin_common.Invalid Setting')); return redirect(url('admin/settings')); } } /** * form is submitted check values and save if needed */ if ($request->isMethod('post')) { /** * validate data */ $rules = ['setting_value' => 'required']; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { $this->throwValidationException($request, $validator); } /** * get data from form */ $data = $request->all(); /** * save or update */ if (!isset($modelData->setting_id)) { Settings::create($data); } else { $modelData->update($data); } /** * clear cache, set message, redirect to list */ Cache::flush(); session()->flash('message', trans('admin_common.Setting saved')); return redirect(url('admin/settings')); } return view('admin.settings.settings_edit', ['modelData' => $modelData]); }
public function settingDestroy($id, Request $request) { if ($this->auth->user()->rank != 3) { abort(403); } if ($request->get("action") == 'ranks') { $rank = Ranks::findOrFail($id); $rank->delete(); return redirect(action('AdminController@settings'))->with('success', 'Le grade à bien été supprimer'); } elseif ($request->get("action") == 'settings') { $setting = Settings::findOrFail($id); $setting->delete(); return redirect(action('AdminController@settings'))->with('success', 'L\'action à bien été effectuer'); } }