Download the PHP package kiritokatklian/laravel-sort-request without Composer
On this page you can find all versions of the php package kiritokatklian/laravel-sort-request. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kiritokatklian/laravel-sort-request
More information about kiritokatklian/laravel-sort-request
Files in kiritokatklian/laravel-sort-request
Package laravel-sort-request
Short Description Sorting logic for your requests, simplified.
License MIT
Homepage https://github.com/kurozora/laravel-sort-request
Informations about the package laravel-sort-request
Sorting logic for your requests, simplified!
Laravel Sort Request
This Laravel package makes it easier to implement sorting logic into your app.
Consider the following examples:
Installation
You can download a release and manually include it in your project:
PHP Version | Sort Request Version |
---|---|
PHP 7.3 | Sort Request 1.0 |
PHP 7.4 | Sort Request 2.0 |
PHP 8.0 | Sort Request 2.0 |
Alternatively you can install the package via composer:
Usage
Basic sorting
Add the SortsViaRequest
trait to your Laravel form request.
As shown above, you will also need to implement the getSortableColumns
method into your form request. It should return an array of column names that can be sorted on.
So if you only wanted to allow sorting on the "name" and "price" columns, you would do:
Next, go to your controller and add the sortViaRequest
method as follows:
😎 That's all. You can now sort the models with the "sort" parameter.
Custom sorting
This package also allows you to have custom sorting behavior:
Please refer the custom sorting docs for a guide on how to use this.
Testing
Contributing
Please refer to the Contributing guide to learn how you can help.
Credits
Credits go to kurozora for creating and maintaining the package.
Special thanks
Security
If you happen to find a security vulnerability, we would appreciate you letting us know at [email protected] and allowing us to respond before disclosing the issue publicly.
Getting in Touch
If you have any questions or just want to say hi, join the Kurozora Discord and drop a message on the #development channel.
License
Laravel Sort Request is an Open Source project covered by the MIT.