I can't add sorting select on my search result. I can't make it work. I've added if statement to sort by select statement like this:
//I've tried to add if statement to sort manually by selecting but, no results changing. // AM I MISSING SOMETHING OR HOW DO I FIX IT?
public function search(Request $request){
$cityKey = $request->cityKey;
$key = $request->key;
$doctors = Doctor_list::where('speciality_title', 'LIKE', '%' . $key . '%')->
where('location', 'LIKE', '%' . $cityKey . '%')->
orWhere('doctors_name', 'LIKE', '%' . $key . '%')->
where('location', 'LIKE', '%' . $cityKey . '%')->
orWhere('speciality_type', 'LIKE', '%' . $key . '%')->
where('location', 'LIKE', '%' . $cityKey . '%')->get();
If ($request->get('sortBy') === 'rate'){
dd($doctors->orderBy('rate', 'desc'));
}
return view('healthflex.search', compact('doctors'));
}
<select name="sortBy" class="select"> //THIS IS SELECT STATEMENT
<option>choose</option>
<option class="sorting" value="rate}">rate</option>
<option class="sorting">Popular</option>
<option class="sorting">Ohirgi</option>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire