/** * @param string $slug * @return \Illuminate\View\View */ public function getBlogFrontend($slug = '') { if ($slug == '') { $blog = Blog::first(); } try { $blog = Blog::findBySlugOrIdOrFail($slug); $blog->increment('views'); } catch (ModelNotFoundException $e) { return Response::view('404', array(), 404); } // Show the page return View('blogitem', compact('blog')); }
/** * @param string $slug * @return \Illuminate\View\View */ public function getBlogFrontend($slug = '') { if ($slug == '') { $blog = Blog::first(); } try { $blog = Blog::findBySlugOrIdOrFail($slug); $blog->increment('views'); } catch (ModelNotFoundException $e) { return Response::view('404', array(), 404); } $popular = Blog::orderBy('views', 'DESC')->first(); // Show the page return View('blog.show', compact('blog', 'popular')); }