This package is an extension for Laravel4 pagination module.
It provides new functionalities:
- route based url generator
- helpers for template render
To composer.json add: "desmart/pagination": "1.2.*" and then run composer update desmart/pagination.
In app/config/app.php replace line 'Illuminate\Pagination\PaginationServiceProvider', with 'DeSmart\Pagination\PaginationServiceProvider',.
This package should not break compatibility with Laravel pagination module.
To use desmart/pagination with Laravel 4.1 switch to version 1.1.*.
To use desmart/pagination with Laravel 4.0 switch to version 1.0.*.
withQuery()- bind query parameters to url generator (by default query parameters are included). Works only for url generating from routes.withoutQuery()- don't bind query parametersroute($route[, array $parameters])- use given route for generating url to pages (it can be route name, or instance ofIlluminate\Routing\Route)useCurrentRoute()- use current (active) route for url generating
pagesProximity($proximity)- set pages proximitygetPagesRange()- get list of pages to show in template (includes proximity)canShowFirstPage()- check if can show first page (returnsTRUEwhen first page is not in list generated bygetPagesRange())canShowLastPage()- check if can show last page (returnsTRUEwhen last page is not in list generated bygetPagesRange())
// example route (app/routes.php)
Route::get('/products/{page}.html', array('as' => 'products.list', 'uses' => ''));
// use the current route
$list = Product::paginate(10)
->useCurrentRoute()
->pagesProximity(3);
// use custom route
$list = Product::paginate(10)
->route('products.list')
->pagesProximity(3);// app/view/products/list.blade.php
@foreach ($list as $item)
{{-- show item --}}
@endforeach
{{ $list->links('products.paginator') }}
// app/view/products/paginator.blade.php
@if ($paginator->getLastPage() > 1)
@foreach ($paginator->getPagesRange() as $page)
{{ $page }}
@endforeach
@endifThis package is open-sourced software licensed under the MIT license
