desmart/pagination
最新稳定版本:1.2.1
Composer 安装命令:
composer require desmart/pagination
包简介
Laravel pagination on steroids
关键字:
README 文档
README
This package is an extension for Laravel4 pagination module.
It provides new functionalities:
- route based url generator
- helpers for template render
Installation
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',.
Compatibilty
This package should not break compatibility with Laravel pagination module.
Laravel 4.1
To use desmart/pagination with Laravel 4.1 switch to version 1.1.*.
Laravel 4.0
To use desmart/pagination with Laravel 4.0 switch to version 1.0.*.
Method overview
General usage
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
For templates
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 usage
In controller
// 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);
In view
// 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 @endif
License
This package is open-sourced software licensed under the MIT license
统计信息
- 总下载量: 9.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 41
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-06-11