Answer the question
In order to leave comments, you need to log in
How to implement multi-filter?
Tell. How to implement a job filter with pagination? Displaying all jobs with pagination was not difficult.
It will also not be difficult if, for example, the URL is of the form www.ru?city=ms.
But how to implement it if, for example, it will be www.ru?city=ms&type=1&var=0 ?
Right now it's just like this:
public function index(Request $request)
{
$jobs = Job::where('status', 1)->paginate(15);
return view('index')->with('jobs', $jobs);
}
Answer the question
In order to leave comments, you need to log in
Thank you all!) I am attaching the finished version.
public function index(Request $request)
{
$city = $request->city;
$experience = $request->experience;
$type = $request->type;
$schedule = $request->schedule;
$jobs = Job::when($city, function ($query) use ($city) {
return $query->where('city', $city);
})
->when($type, function ($query) use ($type) {
return $query->where('type', $type);
})
->paginate(15);
return view('index')->with('jobs', $jobs);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question