deeplace / rankable
There is no license information available for the latest version (dev-master) of this package.
Provides useful methods to make an eloquent collection rankable
dev-master
2026-03-30 11:29 UTC
Requires
- php: >=5.4.0
- illuminate/database: ~5.0
This package is not auto-updated.
Last update: 2026-03-30 14:58:26 UTC
README
add in composer
"repositories": [ { "type": "vcs", "url": "git@gitlab.top.md:terranet/rankable.git" } ], "require": { "terranet/rankable": "dev-master" }
composer update
Usage example
class Program extends Repository implements Translatable, Rankable { use HasRankableField; // optional protected $rankableColumn = 'rank'; protected $rankableIncrementValue = 2; protected $rankableGroupByColumn = 'member_id'; }
now Program::all() will contain orderBy('rank', 'asc') statement
to disable default orderBy statement use:
Program::unRanked()
to sync rankings call:
$model = new Program; $model->syncRanking([ 1 => 3, 2 => 2, 3 => 1 ]);
where key => id, value => rank