/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $search = ''; if ($search = $request->input('search')) { $tweets = Tweet::where('title', "LIKE", "%" . $search . "%")->orWhere('body', "LIKE", "%" . $search . "%")->paginate(10); } else { $tweets = Tweet::simplePaginate(5); //Tweet::all() } $users = User::all(); $tags = ['foo', 'bar']; $latests = Tweet::take(5)->get(); return view('home', compact('tweets', 'search', 'users', 'tags', 'latests')); }