/** * Display an admin page. * * @param Request $request * * @return Response */ public function admin(Request $request) { $contents = Content::with('type')->with('category')->paginate(); $q = $request->get('q', null); $foundContents = []; if (!empty($q)) { $like = '%' . $q . '%'; $foundContents = Content::where(function ($query) use($like) { $query->where('title', 'LIKE', $like)->orWhere('summary', 'LIKE', $like)->orWhere('body', 'LIKE', $like); })->get(); } return view('contents.admin', compact('contents', 'q', 'foundContents')); }