Bring Laravel 8's cursor pagination to Laravel 6, 7

Overview

Laravel Cursor Paginate for laravel 6,7

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Installation

You can install the package via composer:

composer require vanthao03596/laravel-cursor-paginate

Usage

Similar to simplePaginate, cursorPaginate displays "Next" and "Previous" links in your application's UI. You may use the cursorPaginate method like so:

$users = DB::table('users')->orderBy('id')->cursorPaginate(15);

Similarly, you may use the cursorPaginate method to cursor paginate Eloquent models:

$users = User::where('votes', '>', 100)->orderBy('id')->cursorPaginate(15);

When working with resources, you need to use trait HasCursorPaginate to your Resource class:

use Illuminate\Http\Resources\Json\ResourceCollection;
use Vanthao03596\LaravelCursorPaginate\HasCursorPaginate;

class YourCollectionResource extends ResourceCollection
{
    use HasCursorPaginate;

    public $collects = YourResource::class;
}

Cursor Paginator Instance Methods

Each cursor paginator instance provides additional pagination information via the following methods:

Method Description
$paginator->count() Get the number of items for the current page.
$paginator->cursor() Get the current cursor instance.
$paginator->getOptions() Get the paginator options.
$paginator->hasPages() Determine if there are enough items to split into multiple pages.
$paginator->hasMorePages() Determine if there are more items in the data store.
$paginator->getCursorName() Get the query string variable used to store the cursor.
$paginator->items() Get the items for the current page.
$paginator->nextCursor() Get the cursor instance for the next set of items.
$paginator->nextPageUrl() Get the URL for the next page.
$paginator->onFirstPage() Determine if the paginator is on the first page.
$paginator->perPage() The number of items to be shown per page.
$paginator->previousCursor() Get the cursor instance for the previous set of items.
$paginator->previousPageUrl() Get the URL for the previous page.
$paginator->setCursorName() Set the query string variable used to store the cursor.
$paginator->url($cursor) Get the URL for a given cursor instance.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
Laravel Segment is an opinionated, approach to integrating Segment into your Laravel application.

Laravel Segment Laravel Segment is an opinionated, approach to integrating Segment into your Laravel application. Installation You can install the pac

Laravel Sanctum support for Laravel Lighthouse
Laravel Sanctum support for Laravel Lighthouse

Lighthouse Sanctum Add Laravel Sanctum support to Lighthouse Requirements Installation Usage Login Logout Register Email Verification Forgot Password

A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.
A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

Install Install via composer. $ composer require olliecodes/laravel-etched-blade Once installed you'll want to publish the config. $ php artisan vendo

A light weight laravel package that facilitates dealing with arabic concepts using a set of classes and methods to make laravel speaks arabic

A light weight laravel package that facilitates dealing with arabic concepts using a set of classes and methods to make laravel speaks arabic! concepts like , Hijri Dates & Arabic strings and so on ..

Jetstrap is a lightweight laravel 8 package that focuses on the VIEW side of Jetstream / Breeze package installed in your Laravel application

A Laravel 8 package to easily switch TailwindCSS resources generated by Laravel Jetstream and Breeze to Bootstrap 4.

Laravel Jetstream is a beautifully designed application scaffolding for Laravel.

Laravel Jetstream is a beautifully designed application scaffolding for Laravel. Jetstream provides the perfect starting point for your next Laravel application and includes login, registration, email verification, two-factor authentication, session management, API support via Laravel Sanctum, and optional team management.

Laravel Larex lets you translate your whole Laravel application from a single CSV file.
Laravel Larex lets you translate your whole Laravel application from a single CSV file.

Laravel Larex Translate Laravel Apps from a CSV File Laravel Larex lets you translate your whole Laravel application from a single CSV file. You can i

A Laravel package that adds a simple image functionality to any Laravel model
A Laravel package that adds a simple image functionality to any Laravel model

Laraimage A Laravel package that adds a simple image functionality to any Laravel model Introduction Laraimage served four use cases when using images

A Laravel extension for using a laravel application on a multi domain setting
A Laravel extension for using a laravel application on a multi domain setting

Laravel Multi Domain An extension for using Laravel in a multi domain setting Description This package allows a single Laravel installation to work wi

Releases(1.0.6)
Owner
Pham Thao
Pham Thao
Bring multi themes support to your Laravel application with a full-featured Themes Manager

Introduction hexadog/laravel-themes-manager is a Laravel package which was created to let you developing multi-themes Laravel application. Installatio

hexadog 86 Dec 15, 2022
A bring-your-own-email-first newsletter service. ✨

Typewrite Typewrite a hosted bring-your-own-email newsletter service for people who need a simplistic and privacy-first newsletter service. The core a

Ryan Chandler 3 Dec 2, 2021
A base API controller for Laravel that gives sorting, filtering, eager loading and pagination for your resources

Bruno Introduction A Laravel base controller class and a trait that will enable to add filtering, sorting, eager loading and pagination to your resour

Esben Petersen 165 Sep 16, 2022
In-place pagination without page refresh by using Backbone.js with Laravel PHP framework

Laravel Backbone - based in-place pagination demo Store application See demo at: http://demos.maxoffsky.com/ajax-pagination/ Tutorial at: http://maxof

Maksim Surguy 41 Oct 11, 2022
Laravel 7 Ajax Pagination Example

Now, let's see post of Laravel ajax pagination with jQuery. We will look at example of Laravel pagination json. In this article, we will implement a jQuery ajax pagination in Laravel . You can understand a concept of Laravel ajax bootstrap pagination. Here, Creating a basic example of pagination jQuery ajax Laravel

Wesley Sinde 3 Feb 23, 2022
A lightweight PHP paginator, for generating pagination controls in the style of Stack Overflow and Flickr.

PHP Paginator A lightweight PHP paginator, for generating pagination controls in the style of Stack Overflow and Flickr. The "first" and "last" page l

Jason Grimes 370 Dec 21, 2022
List of 77 languages for Laravel Framework 4, 5, 6, 7 and 8, Laravel Jetstream , Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova and Laravel Spark.

Laravel Lang In this repository, you can find the lang files for the Laravel Framework 4/5/6/7/8, Laravel Jetstream , Laravel Fortify, Laravel Cashier

Laravel Lang 6.9k Jan 2, 2023
⚡ Laravel Charts — Build charts using laravel. The laravel adapter for Chartisan.

What is laravel charts? Charts is a Laravel library used to create Charts using Chartisan. Chartisan does already have a PHP adapter. However, this li

Erik C. Forés 31 Dec 18, 2022
Laravel Kickstart is a Laravel starter configuration that helps you build Laravel websites faster.

Laravel Kickstart What is Laravel Kickstart? Laravel Kickstart is a Laravel starter configuration that helps you build Laravel websites faster. It com

Sam Rapaport 46 Oct 1, 2022
Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

null 9 Dec 14, 2022