Pagination for search results laravel 5.3

前端 未结 10 1582
无人及你
无人及你 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:50

    $searchdata =  \Request::get( 'inputTextFieldname' ); \make as global
    $searchresult = Modelname::where ( 'blogpost_title', 'LIKE', '%' .$searchdata . '%' )->paginate(2);
    return view( 'search', compact('searchresult') );
    

    and in your view page

    {{$searchresult->appends(Request::only('inputTextFieldname'))->links()}}
    

    make your route to get method

    Route::get('/search', ['as' => 'search', 'uses' => 'searchController@index']);
    

    this will be done, thanks,

提交回复
热议问题