Laravel分页链接不包括其他GET参数 [英] Laravel Pagination links not including other GET parameters

查看:272
本文介绍了Laravel分页链接不包括其他GET参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



问题:当URL中有一些GET参数时,例如: http://site.com/users?gender=female&body=hot ,生成的分页链接只包含页面参数,没有别的。



刀片模板

 code> {{$ users-> link()}} 

有一个 - > append()函数,但是当我们不知道有多少GET参数时,我们如何使用 append() 在分页链接中包含其他GET参数,而不包含的整个块,如果代码弄乱了我们的刀片模板?

解决方案

编辑:Connor的评论与Mehdi的答案是必须的,使这项工作。感谢两者的澄清。



- > appends()可以接受一个数组作为参数,你可以通过 Input :: except('page'),这应该是诀窍。



示例: p>

  return view('manage / users',[
'users'=> $ users->追加(Input :: except('page'))
]);


I am using Eloquent together with Laravel 4's Pagination class.

Problem: When there are some GET parameters in the URL, eg: http://site.com/users?gender=female&body=hot, the pagination links produced only contain the page parameter and nothing else.

Blade Template

{{ $users->link() }}

There's a ->append() function for this, but when we don't know how many of the GET parameters are there, how can we use append() to include the other GET parameters in the paginated links without a whole chunk of if code messing up our blade template?

解决方案

EDIT: Connor's comment with Mehdi's answer are required to make this work. Thanks to both for their clarifications.

->appends() can accept an array as a parameter, you could pass Input::except('page'), that should do the trick.

Example:

return view('manage/users', [
    'users' => $users->appends(Input::except('page'))
]);

这篇关于Laravel分页链接不包括其他GET参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆