/** * About Us page * * @return $this */ public function about() { $pageContent = Page::where('slug', 'about-us')->get()->first(); $contents = PageContent::where('page_id', $pageContent->id)->get()->first(); $data = ['parentPage' => 'Company', 'page' => 'About Us', 'title' => 'Teleaus | About Us Page', 'pageContent' => $pageContent, 'contents' => count($contents) ? $contents : null]; return view('about-us')->with($data); }
/** * 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, ['title' => 'required', 'details' => 'required']); $page = Page::findOrFail($id); $name = ucfirst(str_replace('-', ' ', $request->name)); if (count($page)) { $page->title = $request->title; $page->name = $name; $page->details = $request->details; $page->slug = $request->name; $page->save(); } $pageContent = PageContent::where('page_id', $id)->get()->first(); $pageContent->page_id = $id; if (!empty($request->mission) || !empty($request->vission) || !empty($request->values) || !empty($request->services)) { if (count($pageContent)) { $pageContent->mission = $request->mission; $pageContent->vission = $request->vission; $pageContent->values = $request->values; $pageContent->services = $request->services; } else { $pageContent = new PageContent(); $pageContent->page_id = $id; $pageContent->mission = $request->mission; $pageContent->vission = $request->vission; $pageContent->values = $request->values; $pageContent->services = $request->services; } } $pageContent->descriptions = $request->descriptions; $pageContent->description_one = $request->description_one; $pageContent->description_two = $request->description_two; if (isset($request->image)) { $imageName = time() . '-1' . '.' . \Input::file('image')->getClientOriginalExtension(); $imagePath = public_path('/uploads/pages/images/' . $imageName); $imageResize = \Image::make(\Input::file('image'))->resize(400, 290)->save($imagePath); $pageContent->image = $imageName; } if (isset($request->image_one)) { $imageNameOne = time() . '-2' . '.' . \Input::file('image_one')->getClientOriginalExtension(); $imagePathOne = public_path('/uploads/pages/images/' . $imageNameOne); $imageResizeOne = \Image::make(\Input::file('image_one'))->resize(400, 290)->save($imagePathOne); $pageContent->image_one = $imageNameOne; } if (isset($request->image_two)) { $imageNameTwo = time() . '-3' . '.' . \Input::file('image_two')->getClientOriginalExtension(); $imagePathTwo = public_path('/uploads/pages/images/' . $imageNameTwo); $imageResizeTwo = \Image::make(\Input::file('image_two'))->resize(400, 290)->save($imagePathTwo); $pageContent->image_two = $imageNameTwo; } $pageContent->save(); Session::flash('message', 'Successfully Updated Page Content !'); return redirect("/all/page"); }