Package Data | |
---|---|
Maintainer Username: | konsulting |
Maintainer Contact: | keoghan@klever.co.uk (Keoghan Litchfield) |
Package Create Date: | 2017-03-16 |
Package Last Update: | 2023-01-23 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 15:01:59 |
Package Statistics | |
---|---|
Total Downloads: | 453 |
Monthly Downloads: | 3 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
A set of utilities for sorting models in Laravel.
Install using composer: composer require konsulting/laravel-sorting
Konsulting\Laravel\Sorting\Sortable
trait to your model.$sortableSettings
property providing the allowed sortable fields and a default sort order.protected static $sortableSettings = [
'sortable' => ['name', 'created_at', 'updated_at'],
'defaultSort' => '+name',
];
{{ App\Post::sortableLink('name', 'Name') }}
sort()
method.App\Post::sort()->paginate();
// The sort method will extract the sort variable from the request, unless you pass them through (e.g. if you store in the session).
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.
If you find any security issues, or have any concerns, please email keoghan@klever.co.uk, rather than using the issue tracker.
Contributions are welcome and will be fully credited. We will accept contributions by Pull Request.
Please:
We use PHPUnit.
Run tests using PHPUnit: vendor/bin/phpunit