2017 © Pedro Peláez
 

library pagination

Laravel pagination on steroids

image

thinkme/pagination

Laravel pagination on steroids

  • Thursday, January 11, 2018
  • by thinkworld
  • Repository
  • 1 Watchers
  • 2 Stars
  • 198 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 2 % Grown

The README.md

Overview

if use laravel4.0/laravel4.1/laravel4.2 click this: https://packagist.org/packages/desmart/pagination, (*1)

This package is an extension for Laravel5 pagination module. Modified from desmart / pagination Thanks radmen https://github.com/DeSmart/pagination, (*2)

It provides new functionalities:, (*3)

  • route based url generator
  • helpers for template render

Installation

To composer.json add: "thinkme/pagination": "dev-master" and then run composer update thinkme/pagination., (*4)

Compatibilty

This package should not break compatibility with Laravel pagination module., (*5)

Laravel 5.0/5.1/5.2/5.3/5.4/5.5

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 parameters
  • route($route[, array $parameters]) - use given route for generating url to pages (it can be route name, or instance of Illuminate\Routing\Route)

For templates

  • pagesProximity($proximity) - set pages proximity
  • getPagesRange() - get list of pages to show in template (includes proximity)
  • canShowFirstPage() - check if can show first page (returns TRUE when first page is not in list generated by getPagesRange())
  • canShowLastPage() - check if can show last page (returns TRUE when last page is not in list generated by getPagesRange())

Example usage

In router

// example route (routes.php)
Route::get('list-{page}.html', ['as' => 'list.page', 'uses' => 'PhotoController@index']);

In controller

// IF use the current route
$list = new Paginator();
$list = list->make($item, $count, 1, $page, [
            'path' => Paginator::resolveCurrentPath(),
        ]);
$list->route('list.page');
$list->pagesProximity(3);

// or quick paginator
$query = User::select($columns);
$paginate = new Paginator();
$paginate->paginate($query, 10);//or $paginate->paginate($query, $perPage, $currentPage);
//or $list = $paginate ^#*&!^#*!^&*(!&#) You know;
//return $list
return $paginate;

//IF you do not want to use the default page name. Example: http://test.com?page=1 to http://test.com?p=1
$paginate->paginate($query, $perPage, $currentPage, ['pageName' => 'p']);//http://test.com?p=1
//or
$paginate->setPageName('p');

// IF use yourself Presenter Class
Paginator::presenter(function() use ($list) {
            return new MyPresenter($list);
        });

In view

// list.blade.php

@foreach ($list as $item)
{{-- show item --}}
@endforeach

{!! $list->links('paginator') !!}

// if use yourself Presenter Class

{!! $list->render() !!}

// paginator.blade.php

@if ($paginator->lastPage() > 1)
  @foreach ($paginator->getPagesRange() as $page)
    {{ $page }}
  @endforeach
@endif

// or this

@if ($paginator->lastPage() > 1)





@endif

License

This package is open-sourced software licensed under the MIT license, (*6)

The Versions

11/01 2018

dev-master

9999999-dev

Laravel pagination on steroids

  Sources   Download

MIT

The Requires

 

by Avatar thinkworld

laravel pagination

17/02 2017

5.3.x-dev

5.3.9999999.9999999-dev

Laravel pagination on steroids

  Sources   Download

MIT

The Requires

 

by Avatar thinkworld

laravel pagination