Pagination for search results laravel 5.3

前端 未结 10 1384
无人及你
无人及你 2021-02-01 06:17

Pagination search results

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

10条回答
  •  醉话见心
    2021-02-01 06:48

    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());
        }
    

提交回复
热议问题