PHP code example of desmart / pagination
1. Go to this page and download the library: Download desmart/pagination library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
desmart / pagination example snippets
// 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
@endif