skip to Main Content

I am doing data output with pagination on laravel. Everything works great. I have my own pagination template. It’s written like this:

{{ $houses->links('catalogs.paginate') }}

However, when I still search for data on the page by some parameters, the GET parameters do not get into pagination.

I tried to write like this:

{{ $houses->links(‘catalogs.paginate’)->withQueryString() }}

Or

controller

public function Category($cat, Request $request) {
$houses = House::with('areas')->where('format_house', '=', $format_house)->paginate(4)->appends(request()->query());
return view('category_catalog', compact('title', 'houses'));
}

Maket

{{ $houses->links('catalogs.paginate') }}

Nothing helps. How to do it right?

2

Answers


  1. You’re already close, the arrangement of the methods you’re calling is incorrect, you must call the links method last.

    $houses->paginate(15)->withQueryString()->links('catalogs.paginate')
    

    OR

    $houses->paginate(15)->appends(request()->query())->links('catalogs.paginate')
    
    Login or Signup to reply.
  2. Try this

    {{ $houses->appends($_GET)->links(‘catalogs.paginate’) }}

    OR

    {{ $houses->appends(request()->query())->links(‘catalogs.paginate’) }}

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search