Closed igor-kamil closed 9 years ago
Actually that "bug" was caused by the way Laravel's Paginator handles getCurrentPage
. It has a check that doesn't let the current page to become greater than the last page:
// Illuminate\Pagination\Paginator
if (is_numeric($page) && $page > $lastPage)
{
return $lastPage > 0 ? $lastPage : 1;
}
Fortunately, the check can be bypassed by calling getCurrentPage
directly on the factory.
I'll make a commit in a couple minutes with the solution, so I'm closing the merge request. Thanks for bringing that up.
Pushed the commit. Take a look and let me know of any problem.
thank you fadion! yes - your approach is better
I decided to solve it in another way. to use manual pagination. (what is making it slightly more effective.) maybe someone will find it useful:
$page = \Input::get(Paginator::getPageName(), 1);
$offset = ($page * $per_page) - $per_page;
$params["from"] = $offset;
$params["size"] = $per_page;
// (...) other search parameters
$items = Item::search($params);
$paginator = Paginator::make($items->all(), $items->total(), $per_page);
pagination in Bouncy behaves in different way, what can cause troubles (e.g. when implementing infinite scroll)
using the Eloquent - when the requested page is out of range - no results are returned
but in Bouncy implementation it returns the results from the last page - what is causing infinite scroll looping the last page forever (making it realy infinite :)
this fix is making it behaving the same way as in Eloquent (when requesting page out of range - returns the empty array)