Level 33
you need to override the Paginator::currentPageResolver() to current page ID
you will override this function in PaginationServiceProvider as the property is protected and there's no getter.
Paginator::currentPageResolver(10);
$users = User::paginate(); // you now will be on page 10
public function register()
{
Paginator::viewFactoryResolver(function () {
return $this->app['view'];
});
Paginator::currentPathResolver(function () {
return $this->app['request']->url();
});
Paginator::currentPageResolver(function ($pageName = 'page') {
$page = $this->app['request']->input($pageName);
if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
return (int) $page;
}
return 1;
});
Paginator::queryStringResolver(function () {
return $this->app['request']->query();
});
}
https://stackoverflow.com/questions/60901176/set-current-page-in-laravel-6-paginate-without-page-2