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);
you can easy and simply Pagination current Button in laravel. we can add current link on pagination using simplePaginate() in laravel 6, laravel 7 and laravel 8 application. laravel provide new eloquent method simplePaginate() for adding simple pagination with only current button link.
Use Pagination in Laravel Implementing pagination in laravel is smooth, add the laravel paginate function in the getData() function inside the EmployeeController class. Remove all() and use paginate() and it takes a number as an argument, that number defines the number of results to be shown to the user.
The pagination option specifies which view should be used to create pagination links. By default, Laravel includes two views. The pagination::slider view will show an intelligent "range" of links based on the current page, while the pagination::simple view will simply show "previous" and "next" buttons.
I looked at the API --- turns out this is much easier now in 2014.
All you have to do is set
Paginator::setCurrentPage(2);
any time before you call ->paginate()
, I believe, and it should override the page set (or not set) by ?page=
.
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(...);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With