public function index(News $news, NewsComment $newsComment, Request $request) { if (isset($_POST['sort'])) { $input = \Input::all(); $sort = $input['sort']; $sortBy = $input['sortBy']; $this->data['records'] = $news->getActiveSort($sort, $sortBy); } else { $this->data['records'] = $news->getActive(); } $this->newsComment($newsComment); $this->data['top_views_records'] = $news->top_views_getActive(); $this->data['top_last_records'] = $news->top_last_getActive(); if ($request->ajax()) { return response()->json(view('news.ajaxPaginate.Index', $this->data)->render()); } return view('news.index', $this->data); }