Download the PHP package aloware/laravel-cursor-pagination without Composer

On this page you can find all versions of the php package aloware/laravel-cursor-pagination. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-cursor-pagination

Aloware - Laravel Cursor Pagination

This package provides cursor based pagination for Laravel's Query Builder and Eloquent ORM. It calculates the SQL query limits automatically by checking the requests GET parameters, and automatically builds the next and previous urls for you.

Compatibility

This package is tested on Laravel 5.6, and we expect it to work on newer versions, but it was never tested.

Installation

You can install this package via composer using:

The package will automatically register itself.

How does it work

The main idea behind a cursor pagination is that it needs a context to know what results to show next. So instead of saying page=2, you say:

and the cursor value is encoded(base64). If you decode it, you'll we something like:

The result is the same as the old fashioned page pagination, but now you have more control on the output, cause it should always return the same.

This kind of pagination is useful when you sort using the latest first, so you can keep an infinite scroll using cursor whenever you get to the bottom, or do a cursor whenever you need to refresh the list at the top, and if you send the first cursor, the results will only fetch the new ones.

Basic Usage

Paginating Query Builder Results

There are several ways to paginate items. The simplest is by using the cursorPaginate method on the query builder or an Eloquent query. The cursorPaginate method automatically takes care of setting the proper limit and fetching the next or previous elements based on the cursor being viewed by the user. By default, the cursor is detected by the value of the page query string argument on the HTTP request. This value is automatically detected by the package taking your custom config into account, and is also automatically inserted into links and meta generated by the paginator.

``

Paginating Eloquent Results

You may also paginate Eloquent queries. In this example, we will paginate the User model with 15 items per page. As you can see, the syntax is identical to paginating query builder results:

``

Of course, you may call paginate after setting other constraints on the query, such as where clauses:

``

Or sorting your results:

``

Don't worry, the package will detect if the model's primary key is being used for sorting, and it will adapt itself so the next and previous work as expected.

Identifier

The paginator identifier is basically the cursor attribute. The model's attribute that will be used for paginating. It's really important that this identifier is unique on the results. Duplicated identifiers could cause that some records are not showed, so be careful.

Auto-detecting Identifier

If no identifier is defined, the cursor will try to figure it out by itself. First, it will check if there's any orderBy clause. If there is, it will take the first column that is sorted and will use that. If there is not any orderBy clause, it will check if it's an Eloquent model, and will use it's primaryKey (by default it's 'id'). And if it's not an Eloquent Model, it'll use id.

Example

``

``

``

Customizing Identifier

Just define the identifier option

``

Credits

License

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


All versions of laravel-cursor-pagination with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.0
illuminate/support Version ^5.5|^6|^7|^8
illuminate/http Version ^5.5|^6|^7|^8
illuminate/database Version ^5.5|^6|^7|^8
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package aloware/laravel-cursor-pagination contains the following files

Loading the files please wait ....