Laravel分页链接不包括其他GET参数 [英] Laravel Pagination links not including other GET parameters
问题描述
问题:当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屋!