Download the PHP package a-dob/preview-paginator without Composer
On this page you can find all versions of the php package a-dob/preview-paginator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download a-dob/preview-paginator
More information about a-dob/preview-paginator
Files in a-dob/preview-paginator
Package preview-paginator
Short Description Laravel pagination with different size for first page (preview-paginator)
License MIT
Informations about the package preview-paginator
Laravel pagination for models with different page sizes (preview-paginator)
This package allows you to add a local scope to your Model.
The Pagination class implements the
contract and it is similar to the basic simplePaginate method.
Installation
composer require a-dob/preview-paginator
Add PreviewPaginated trait to models
Add trait to your model you want to paginate
The property sets the number of returned models on the first page by default.
The property sets the number of returned models on the remaining pages by default.
Usage
You may paginate Eloquent queries. In this example, we will paginate the model and indicate that we plan to display 5 records on first page and 15 records on the remaining pages. As you can see, the syntax is nearly identical to paginating query builder results:
Of course, you may call the previewPaginate method after setting other constraints on the query, such as where clauses:
You may also use the previewPaginate method when paginating Eloquent models:
The first argument of the previewPaginated method specifies the number of returned models on the first page.
The second argument of the previewPaginated method specifies the number of returned models on the remaining pages.
If null is passed as the first argument, the initial quantity will be defined from the specified model property. If this property is not defined in the model the initial quantity will be