Example #1
0
 /**
  * Show a news
  * 
  * @param  int      $id     The ID of the news
  * @param  string   $slug   The unique slug
  * @return void
  */
 public function show($id, $slug = null)
 {
     if ($id) {
         $news = News::whereId($id)->published()->firstOrFail();
     } else {
         $news = News::whereSlug($slug)->published()->firstOrFail();
     }
     $hasAccess = (user() and user()->hasAccess('internal'));
     if ($news->internal and !$hasAccess) {
         return $this->alertError(trans('app.access_denied'));
     }
     $news->access_counter++;
     $news->save();
     $this->title($news->title);
     $this->openGraph($news->openGraph());
     $this->pageView('news::show', compact('news'));
 }