PHPackages                             leparking/laravel-sortable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. leparking/laravel-sortable

ActiveLibrary[Database &amp; ORM](/categories/database)

leparking/laravel-sortable
==========================

Laravel package to sort Eloquent models

0.2.0(10y ago)047MITPHPPHP &gt;=5.5.9

Since May 11Pushed 10y ago1 watchersCompare

[ Source](https://github.com/leparking/laravel-sortable)[ Packagist](https://packagist.org/packages/leparking/laravel-sortable)[ Docs](https://github.com/leparking/laravel-sortable)[ RSS](/packages/leparking-laravel-sortable/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Laravel Sortable
================

[](#laravel-sortable)

A Laravel 5.2 package to sort Eloquent models.

[![Build Status](https://camo.githubusercontent.com/bb2311ae41635cf4655fd0908542350f933f9426c16ae09d998c013d3538b017/68747470733a2f2f7472617669732d63692e6f72672f6c657061726b696e672f6c61726176656c2d736f727461626c652e737667)](https://travis-ci.org/leparking/laravel-sortable)

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Similar Packages](#similar-packages)

Installation
------------

[](#installation)

Require the package with composer

```
composer require leparking/laravel-sortable
```

Add the service provider to `config/app.php`

```
    'providers' => [
        // ...
        LeParking\Sortable\SortableServiceProvider::class,
    ],
```

Configuration
-------------

[](#configuration)

Publish the default configuration file to `config/sortable.php`

```
php artisan vendor:publish
```

The settings in this file will apply to all sortable models, but can be overridden on each model with the `$sortable` property.

Here are the available settings with their defaults:

```
return [
     // Name of the column that will store the position.
    'column' => 'position',

     // If set to true, new models will be inserted at the first position.
    'insert_first' => false,

     // A column name or an array of columns names to group sortable models.
    'group_by' => false,
];
```

Usage
-----

[](#usage)

Your sortable models should implement the `Sortable` interface and use the `SortableTrait`.

```
use Illuminate\Database\Eloquent\Model;
use LeParking\Sortable\Sortable;
use LeParking\Sortable\SortableTrait;

class Book extends Model implements Sortable
{
    use SortableTrait;

    // Optional property to override default settings.
    protected $sortable = [
        // ...
    ];
}
```

The database table must have an integer column to store the position.

```
Schema::create('books', function($table) {
    $table->integer('position')->unsigned();
});
```

The `position` attribute will be filled automatically when creating new models.

```
$book = Book::create();
echo $book->position; // 1

$book2 = Book::create();
echo $book2->position; // 2
```

The `SortableTrait` provides a query scope to retrieve models ordered by the position column.

```
$books = Book::ordered();
$books = Book::ordered('desc');
```

Similar Packages
----------------

[](#similar-packages)

- [spatie/eloquent-sortable](https://github.com/spatie/eloquent-sortable)
- [lookitsatravis/listify](https://github.com/lookitsatravis/listify)
- [boxfrommars/rutorika-sortable](https://github.com/boxfrommars/rutorika-sortable)

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

2

Last Release

3698d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2684640?v=4)[Matthieu Louis](/maintainers/matlouis)[@matlouis](https://github.com/matlouis)

---

Top Contributors

[![matlouis](https://avatars.githubusercontent.com/u/2684640?v=4)](https://github.com/matlouis "matlouis (11 commits)")

---

Tags

laraveleloquentsortable

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/leparking-laravel-sortable/health.svg)

```
[![Health](https://phpackages.com/badges/leparking-laravel-sortable/health.svg)](https://phpackages.com/packages/leparking-laravel-sortable)
```

###  Alternatives

[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M88](/packages/mongodb-laravel-mongodb)[spatie/eloquent-sortable

Sortable behaviour for eloquent models

1.5k24.7M307](/packages/spatie-eloquent-sortable)[spatie/laravel-sluggable

Generate slugs when saving Eloquent models

1.5k12.4M294](/packages/spatie-laravel-sluggable)[watson/validating

Eloquent model validating trait.

9733.4M53](/packages/watson-validating)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k322.4k1](/packages/cybercog-laravel-love)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
