搜索结果的分页 laravel 5.3
问题描述
我刚刚开始使用 Laravel,我正在尝试使用适当的分页来制作搜索功能.该功能适用于第一页,但在第二页上不起作用.我认为它没有将结果提供给下一页,但我似乎找不到答案.
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 page two it doesn't. I think it's not giving the results to the next page but I can't seem to find an answer.
这是我在 IndexController 中的搜索功能:
这是我的路线:
这是第二页的网址:
这就是我显示分页的方式:
错误:
<小时>
根据请求获取错误.
Get error on request.
路线:
错误:
<小时>
我希望我的问题清楚并且格式正确.提前谢谢你(抱歉我的英语不好)
I hope my question is clear and in the right format. Thank you in advance (sorry for my bad English)
答案:
我最终结合了这篇文章的答案并结合了 这个帖子
I ended up using the answer of this post in combination with some help of this post
我在最初的搜索中使用了 post 函数,在接下来的页面中使用了 get 函数.这是可能的,因为我现在正在搜索 URL.
I used a post function for the initial search and a get function for the following pages. This was possible because I'm now giving my search to the URL.
- 添加了初始错误.
- 添加了
Route::get
错误 - 添加答案
推荐答案
如果您想将过滤器应用到下一页,您应该将它们添加到您的分页器中,如下所示:
If you want to apply filters to the next page you should add them to your paginator like this:
并更改您从邮寄到获取的路线:
And change your route from post to get:
这篇关于搜索结果的分页 laravel 5.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!