Download the PHP package ryanwinchester/laravel-paginates without Composer
On this page you can find all versions of the php package ryanwinchester/laravel-paginates. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ryanwinchester/laravel-paginates
More information about ryanwinchester/laravel-paginates
Files in ryanwinchester/laravel-paginates
Package laravel-paginates
Short Description Laravel controller trait for paginating models
License Apache-2.0
Informations about the package laravel-paginates
PaginatesModels
This trait adds a super duper handy method that will give you behaviour from requests slightly similar to what something like league/fractal
gives you without all the setup and needing to create transformers.
Between this trait, and Eloquent Models' $casts
and $hidden
properties, starting a basic API with about as much control as some more heavyweight packages give you, will be really quick.
Install
Usage
Add it to your controller (or base controller, as shown):
Then use it in your controller methods like so:
Sometimes because of security or privacy, you may want to limit include
relationships and/or columns
.
If that is the case, then be sure to include the parameters you want, making sure to exclude any user-supplied include parameters.
Or, say you want to define some included relationships yourself:
Or, even limit to specific columns:
You can pass in any builder instance or a model class name.
Parameters:
- page :
page=3
the page number - perPage :
perPage=10
amount to show per page - columns :
columns=title,body,author
limit to certain columns - include :
include=categories,tags
load relations - orderBy :
orderBy=published|desc
order the items by a column and direction
In action
Then you can go to your route and add some of these optional parameters to page and filter:
Please try it out and give feedback.
Taylor thinks it's a good idea, so I mean what other reason do you need?