I have just started with Laravel and I am trying to make a search function with proper pagination. The function works for page one but on pag
If you are using search form with GET method then use something like these to preserve pagination withing search results.
public function filter(Request $request)
{
$filter = $request->only('name_operator','name_value','email_operator','email_value', 'phone_operator','phone_value', 'gender_value', 'age_operator','age_value');
$contacts = $this->repo->getFilteredList(array_filter($filter));
$contacts->appends($filter)->links(); //Continue pagination with results
return view('dashboard::index', compact('contacts'))->withInput($request->all());
}