0

I found this reply this for a similar question: Laravel 5 - Manual pagination

what is not clear now to me is how to make the front page workin with the classic {{$items->links()}} on blade template.

my controller's code is:

$paginator = new Paginator($risultati, count($risultati),'10');

The problem is that the object that i generate is something like:

    LengthAwarePaginator {#311 ▼
  #total: 11
  #lastPage: 2
  #items: Collection {#312 ▶}
  #perPage: "10"
  #currentPage: 1
  #path: "/"
  #query: []
  #fragment: null
  #pageName: "page"
}

so the problem si in the "path", how can I make it works again? thanks a lot

JahStation
  • 893
  • 3
  • 15
  • 35
  • 1
    It looks like you can set the path on your `$paginator` variable, just use `$paginator->setPath("example")` and see if that helps. Here's the documentation for that component: https://laravel.com/api/5.0/Illuminate/Pagination/LengthAwarePaginator.html#method_setPath – Tim Lewis Mar 19 '18 at 17:27

1 Answers1

0

You can use something like this to pass arguments to LengthAwarePaginator method:

$paginate = 20;

$page = Input::get('page', 1);

$offSet = ($page * $paginate) - $paginate;

$itemsForCurrentPage = array_slice($items, $offSet, $paginate, true);

$result = new \Illuminate\Pagination\LengthAwarePaginator ( $itemsForCurrentPage, count($items), $paginate, LengthAwarePaginator::resolveCurrentPage(),array('path' => LengthAwarePaginator::resolveCurrentPath()));

Community
  • 1
  • 1