public function index(Request $request)
{
$search = $request->input('q');
if($search!=""){
$Members = Member::where(function ($query) use ($search){
$query->where('name', 'like', '%'.$search.'%')
->orWhere('email', 'like', '%'.$search.'%');
})
->paginate(2);
$Members->appends(['q' => $search]);
}
else{
$Members = Member::paginate(2);
}
return View('pages.search')->with('data',$Members);
//
}
public function show(Request $request)
{
$annonces = Annonce::when($request->term, function ($query, $term) {
return $query->where('title', 'like', "%{$term}%");
})->when($request->categorie, function ($query, $categorie) {
return $query->where('categorie', 'like', "%{$categorie}%");
})->when($request->price && in_array($request->price, ['more-expensive', 'less-expensive']), function ($query) use ($request) {
return $query->orderBy('price', $request->price == 'less-expensive' ? 'asc' : 'desc');
}, function ($query) {
return $query->orderByDesc('id');
})->paginate(15);
return view('welcome', compact('annonces'));
}