public function about() { $about = AboutPage::find(1); if (!$about) { abort(404); } return view('static.about', ['p' => 'about', 'text' => $about->text]); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request, $id) { try { $aboutPage = AboutPage::findOrFail($id); } catch (ModelNotFoundException $e) { abort(404); } $validationRules = ['text' => 'required']; $v = Validator::make($request->all(), $validationRules); if ($v->fails()) { return redirect()->back()->withErrors($v->errors())->withInput(); } $aboutPage->text = $request->text; $aboutPage->save(); return redirect('pageTexts')->with('alert-success', 'Текст на странице О компании изменен'); }