Specify a page for pagination - Laravel 4

laravel, laravel-4, pagination

Solution

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);

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(...);

Problem

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? I've tried Input::set('page', $x); but there's no such function. $_GET['page'] = $x; doesn't work too. This the code: ``` $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); ```

Original source