/** * 分页显示整个问题目录. * * @return Response */ public function index(Request $request) { $subArr = array(); //提交的题目 $acArr = array(); //通过的题目 if (Auth::check()) { $subArr = DB::table('solution')->where('user_id', Auth::user()->user_id)->groupBy('problem_id')->lists('problem_id'); $acArr = DB::table('solution')->where('user_id', Auth::user()->user_id)->where('result', '4')->groupBy('problem_id')->lists('problem_id'); } $id = $request->input('id'); $title = $request->input('title'); $data = Problem::paginate(30); if ($id != "") { return $this->show($id); } if ($title != "") { $data = Problem::where('title', 'like', '%' . $title . '%')->paginate(30); return view('problems.index')->with(['problems' => $data, 'subArr' => $subArr, 'acArr' => $acArr]); } return view('problems.index')->with(['problems' => $data, 'subArr' => $subArr, 'acArr' => $acArr, 'pageSaved' => 'true']); }