2017-06-01 16:17
浏览 36

Laravel Pagination with Get请求

I've followed the instructions on the Laravel documentation for pagination with appends([]) however I'm having a little trouble with the persistence of these parameters.

Say for example, I pass home?category=Cars&make=Tesla to my view. What is the best way to paginate with them Get requests?

Right now I've passed the category as a parameter to the view as (where category is the model i've grabbed findOrFail with the request('category');)

$category_name = $category_model->name;

And then in my view it's like so:

{{ $vehicles->appends(['category' => $category_name])->links() }}

But when I go between pages in the pagination, this $category_name value doesn't seem to persist. Whats the recommended way to achieve what I want?


图片转代码服务由CSDN问答提供 功能建议

我按照Laravel文档中的说明进行了 appends([])但是我对这些参数的持久性有点麻烦。

例如,我将 home?category = Cars& make = Tesla 传递给 我的看法。 用它们分页获取请求的最佳方法是什么?

现在我已将类别作为参数传递给视图(其中类别是我抓住了findOrFail的模型) request('category');

  $ category_name = $ category_model-> name; 


  {{$ vehicles-> appends(['category'=> $ category_name])  - > links()}} 

但是当我在分页中的页面之间移动时,此$ category_name值似乎不会持续存在。 什么是推荐的方式来实现我想要的?


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题