Download the PHP package konsulting/laravel-sorting without Composer
On this page you can find all versions of the php package konsulting/laravel-sorting. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download konsulting/laravel-sorting
More information about konsulting/laravel-sorting
Files in konsulting/laravel-sorting
Package laravel-sorting
Short Description A sorting package for laravel
License MIT
Informations about the package laravel-sorting
Sorting
A set of utilities for sorting models in Laravel.
Installation
Install using composer: composer require konsulting/laravel-sorting
Usage
Sorting
- Add the
Konsulting\Laravel\Sorting\Sortable
trait to your model. -
Set up the configuration for the model by adding the
$sortableSettings
property providing the allowed sortable fields and a default sort order. -
In your view where you’d like to add a sortable link, include the following (example for a Post model):
- When you want retrive a sorted collection of models, use the
sort()
method.
Prioritise
-
Add the
Konsulting\Laravel\Sorting\Prioritise
trait to your model. -
Ensure your model has a column for 'priority'. By default, this is called 'priority' but can be overriden if needed by overriding the
determinePriorityColumnName()
method in the model. - Use the
prioritise
scope to sort the retrieved results by priority.
Security
If you find any security issues, or have any concerns, please email [email protected], rather than using the issue tracker.
Contributing
Contributions are welcome and will be fully credited. We will accept contributions by Pull Request.
Please:
- Use the PSR-2 Coding Standard
- Add tests, if you’re not sure how, please ask.
- Document changes in behaviour, including readme.md.
Testing
We use PHPUnit.
Run tests using PHPUnit: vendor/bin/phpunit
All versions of laravel-sorting with dependencies
illuminate/database Version ^5.3 | ^5.4 | ^5.5 | ^5.6 | ^5.7 | ^5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0