public function results(Request $request) { $type = $request->input('type'); $query = $request->input('query'); if ($type == 'user') { $results = User::where('username', 'LIKE', '%' . $query . '%')->paginate(20); } elseif ($type == 'reply') { $results = Reply::where('body_original', 'LIKE', '%' . $query . '%')->paginate(20); } elseif ($type == 'topic') { $results = Topic::where('body_original', 'LIKE', '%' . $query . '%')->paginate(20); } elseif ($type == 'status') { $results = Status::where('body_original', 'LIKE', '%' . $query . '%')->paginate(20); } return view('search.results', compact('type', 'query', 'results')); }
/** * Run the migrations. * * @return void */ public function up() { Topic::where('vote_count', '<', '0')->update(['vote_count' => 0]); Reply::where('vote_count', '<', '0')->update(['vote_count' => 0]); }