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(9y ago)047MITPHPPHP &gt;=5.5.9

Since May 11Pushed 9y 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 1mo 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 27% 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

3647d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2523de5084cfac33049bc02f229aa170cdab2ac9caefe8b19ec567e4facf8799?d=identicon)[matlouis](/maintainers/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

[spatie/eloquent-sortable

Sortable behaviour for eloquent models

1.5k22.9M266](/packages/spatie-eloquent-sortable)[rutorika/sortable

Adds sortable behavior and ordering to Laravel Eloquent models. Grouping and many to many supported.

299992.5k14](/packages/rutorika-sortable)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[jedrzej/sortable

Sortable trait for Laravel's Eloquent models - sort your models using request parameters

54261.0k1](/packages/jedrzej-sortable)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)

PHPackages © 2026

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