Laravel Pagination Without A Model
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
Answer
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()));
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?