/** * * 單文頁 */ public function article($id) { try { $article = Article::open()->where('id', '=', $id)->first(); if ($article) { //瀏覽數 if (helper::views_cookie('article', $id)) { $article->views = $article->views + 1; $article->save(); } //套用不同版型 if ($article->category == '1') { //關於煥儷 return View::make('aesthetics.about.index')->with('article', $article); } elseif ($article->category == '2') { //海外專區 return View::make('aesthetics.overseas.index')->with('article', $article); } elseif ($article->category == '3') { //最新消息 //上一篇 ID $previousId = Article::ofCategory('3')->where('id', '<', $article->id)->orderBy('id', 'DESC')->max('id'); //下一篇 ID $nextId = Article::ofCategory('3')->where('id', '>', $article->id)->orderBy('id', 'DESC')->min('id'); return View::make('aesthetics.news.post')->with(array('article' => $article, 'prev' => Article::find($previousId), 'next' => Article::find($nextId))); } } else { return Redirect::to('/'); } } catch (Exception $e) { return Redirect::to('/'); } }