New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

stepanenko3/laravel-pagination

Great pagination generator for Laravel
164,364 7
Install
composer require stepanenko3/laravel-pagination
Latest Version:v1.0.4
PHP:^8.0
Laravel:10 · 11 · 12
License:MIT
Last Updated:Feb 24, 2025
Links: GitHub  ·  Packagist
Maintainer: stepanenko3

Laravel Pagination

Latest Version on Packagist Total Downloads License

Description

Great pagination generator for Laravel

Examples

1, 2, 3, 4, 5, ..., 20

1, ..., 12, 13, 14, ..., 20

1, ..., 16, 17, 18, 19, 20

Requirements

  • php: >=8.0
  • laravel/framework: ^9.0

Installation

# Install the package
composer require stepanenko3/laravel-pagination

Usage

Create your own database builder in app\Builders\BaseBuilder.php

use Stepanenko3\LaravelPagination\Pagination;
use Illuminate\Database\Eloquent\Builder;

class BaseBuilder extends Builder
{
    public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
    {
        $page = $page ?: Pagination::resolveCurrentPage($pageName);
        $perPage = $perPage ?: $this->model->getPerPage();
        $results = ($total = $this->toBase()->getCountForPagination())
            ? $this->forPage($page, $perPage)->get($columns)
            : $this->model->newCollection();

        return new Pagination($results, $total, $perPage, $page, [
            'path' => Pagination::resolveCurrentPath(),
            'pageName' => $pageName,
        ]);
    }
}

Or use without database builder

new Pagination(
    $items,
    $total,
    $perPage,
    $currentPage,
);

Credits

Contributing

Thank you for considering contributing to this package! Please create a pull request with your contributions with detailed explanation of the changes you are proposing.

License

This package is open-sourced software licensed under the MIT license.

Related Packages

sclaravel/menus

Laravel Menus

4,619 2
offload-project/laravel-navigation

Configurable navigation package for Laravel with breadcrumb and tree generation

2,675 5
nwidart/laravel-menus

Laravel Menu management

186,576 167
squipix/laravel-menus

Laravel Menu management

1,772 0
tyondo/menu-generator

Backend navigation menu generator for Laravel 5.3 and 5.4.

192 3

Version History

Version Released PHP Laravel License
v1.0.4 ^8.0 ^10.0|^11.0|^12.0 MIT
v1.0.3 ^8.0 ^10.0|^11.0 MIT
v1.0.2 ^8.0 MIT
v1.0.1 ^8.0 MIT
1.0.0 ^8.0 MIT