指定用于分页的页面-Laravel 4 [英] Specify a page for pagination - Laravel 4

查看:51
本文介绍了指定用于分页的页面-Laravel 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试记住"用户浏览记录时所在的页面,以便当他返回列表时,将返回到他上次退出的页面.

I'm trying to "remember" the page the user was on as he browses through records so that when he returns to the list, he is returned to the page where he left off.

如何更改分页器的当前页面"值?

How do I change the "current page" value for paginator?

我尝试了Input :: set('page',$ x);但是没有这样的功能. $ _GET ['page'] = $ x;也不行.

I've tried Input::set('page', $x); but there's no such function. $_GET['page'] = $x; doesn't work too.

此代码:

$list = Publication::orderBy($this->data['sort_by'], $this->data['order_by']);

foreach ($this->data['filter_data'] AS $field => $value) {
    $list->where($field, 'LIKE', "%$value%");
}

$this->data['list'] = $list->paginate(15);

推荐答案

您可以通过DB连接调整分页环境的页面.

You can adjust the page of the pagination environment through the DB connection.

DB::getPaginator()->setCurrentPage(2);

不太确定,但是您可以通过以下方式浏览模型.

Not entirely sure but you might be able to go through your model with something like this.

Publication::getConnection()->setCurrentPage(2);

如果上述方法不起作用(从您的评论看来),请使用Publication实例.

If the above isn't working (as it seems from your comment), then do it with an instance of Publication.

$publication = new Publication;

$publication->getConnection()->setCurrentPage(2);

$list = $publication->orderBy(...);

这篇关于指定用于分页的页面-Laravel 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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