2017 © Pedro PelĂĄez
 

library laravel-sorting

A sorting package for laravel

image

konsulting/laravel-sorting

A sorting package for laravel

  • Friday, September 8, 2017
  • by konsulting
  • Repository
  • 1 Watchers
  • 0 Stars
  • 109 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 33 % Grown

The README.md

Sorting

A set of utilities for sorting models in Laravel., (*1)

Installation

Install using composer: composer require konsulting/laravel-sorting, (*2)

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.
protected static $sortableSettings = [
    'sortable' => ['name', 'created_at', 'updated_at'],
    'defaultSort' => '+name',
];
  • In your view where you’d like to add a sortable link, include the following (example for a Post model):
{{ App\Post::sortableLink('name', 'Name') }}
  • When you want retrive a sorted collection of models, use the 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).

Prioritise

  • Add the Konsulting\Laravel\Sorting\Prioritise trait to your model., (*3)

  • 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., (*4)

  • Use the prioritise scope to sort the retrieved results by priority., (*5)

Security

If you find any security issues, or have any concerns, please email keoghan@klever.co.uk, rather than using the issue tracker., (*6)

Contributing

Contributions are welcome and will be fully credited. We will accept contributions by Pull Request., (*7)

Please:, (*8)

  • 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., (*9)

Run tests using PHPUnit: vendor/bin/phpunit, (*10)

The Versions

08/09 2017

dev-master

9999999-dev

A sorting package for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

13/02 2017

0.1.2

0.1.2.0

A sorting package for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

19/12 2016

0.1.1

0.1.1.0

A sorting package for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

22/11 2016

0.1.0

0.1.0.0

A sorting package for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires