Download the PHP package amsoell/withable-sortable without Composer
On this page you can find all versions of the php package amsoell/withable-sortable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download amsoell/withable-sortable
More information about amsoell/withable-sortable
Files in amsoell/withable-sortable
Package withable-sortable
Short Description A Laravel package to add eager loading and sorting to your API endpoints
License MIT
Homepage https://github.com/amsoell/withable-sortable
Informations about the package withable-sortable
Laravel withable-sortable
This Laravel package enables dynamic eager loading and sorting in your API controllers.
Installation
You can install the package via composer:
Usage
Add the withable()
and sortable()
calls on any Eloquent queries in your API controllers to automatically enable eager loading and sorting through querystring parameters. An controllerless example:
/users
will return users sorted by the default (created_at
in ascending order)/users?sort=email
will return users sorted by email address/users?sort=email&direction=desc
will return users sorted by email in descending order/users?with=posts
will return users with aposts
relationship eager loaded/users?with[]=posts&with[]=comments
will return users withposts
andcomments
relationships both eager loaded
If you want to specifically eager load some relationships while allowing additional eager loads via with=
, you can specify them in your route method:
You can also set the default sort parameters:
Even when setting default eager loads or sorts, they can be added to or overridden via querystring paramters.
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Andy Soell
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.
All versions of withable-sortable with dependencies
illuminate/http Version ^8.0|^9.0
illuminate/support Version ^8.0|^9.0