Yorkata's avatar

Pagination stacks up pages in the URL

I've got a problem with pagination and one way to fix it is to use appends(request()->query()) $competitions = Competition::orderBy('id', 'DESC')->paginate(2)->appends(request()->query()); But the problem now is that it makes the URL really weird. When you go back and forth it stack up the pages like this http://local:8003/competitions?%2F%2Fcompetitions%3F%2F%2Fcompetitions%3F%2F%2Fcompetitions%3F%2F%2Fcompetitions%3Fpage=2&page=3 Any and all help gratefully received!

0 likes
2 replies
Sinnbeck's avatar

There is a bullt in method for it

$competitions = Competition::orderBy('id', 'DESC')->paginate(2)->withQueryString();

Please or to participate in this conversation.