PHPackages                             hichxm/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hichxm/laravel-sortable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hichxm/laravel-sortable
=======================

Laravel sortable packages for Laravel ecosystem by Hichxm

v1.0.2(2y ago)11851MITPHP

Since Apr 1Pushed 2y ago1 watchersCompare

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

READMEChangelogDependencies (6)Versions (7)Used By (1)

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

[](#laravel-sortable)

Laravel Sortable is a trait that adds sortable behaviour to an Eloquent model.

Supported Laravel Versions
--------------------------

[](#supported-laravel-versions)

Laravel Version**11****10****9**PHP 8.1❌✅✅PHP 8.2✅✅✅PHP 8.3✅✅✅Installation
------------

[](#installation)

You can install the package via composer:

```
composer require hichxm/laravel-sortable
```

Usage
-----

[](#usage)

Create a new migration to add a new column to your table:

```
Schema::table('addresses', function (Blueprint $table) {
    $table->orderColumn('order');

    // $table->dropOrderColumn('order'); // To drop the order column
});
```

Add the `Hichxm\LaravelSortable\HasSortableColumn` trait to your model:

```
use Hichxm\LaravelSortable\HasSortableColumn;

class Address extends Model
{
    use HasSortableColumn;
}
```

By default, the trait will look for a column named `order`, but you can customize this by setting the `$sortableColumn` property on your model:

```
class Address extends Model
{
    use HasSortableColumn;

    protected $sortableColumn = 'custom_order';
}
```

You can now use the following methods on your model to manage order:

```
$addressOne = Address::find(1);
$addressTwo = Address::find(2);
$addressThree = Address::find(3);

Address::swapOrder($addressOne, $addressTwo); // Swap the order of the two addresses
Address::setOrder($addressOne, 2); // Set the order of the address
Address::setNewOrder([$addressOne, $addressTwo, $addressThree]); // Set the order of the addresses
```

You can also use the following methods to get query ordered results:

```
$addressQuery = Address::query();

$addressQuery->ordered()->get(); // Get the addresses ordered

$addressQuery->ordered('desc')->get(); // Get the addresses ordered in descending order
$addressQuery->orderedDesc()->get(); // Get the addresses ordered in ascending order

$addressQuery->ordered('asc')->get(); // Get the addresses ordered in ascending order
$addressQuery->orderedAsc()->get(); // Get the addresses ordered in ascending order
```

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

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 ~0 days

Total

6

Last Release

770d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dd807d572b973124749e77aad69c1c8d51db3070f61ab1be91fbd7a4a82ee010?d=identicon)[Hichxm](/maintainers/Hichxm)

---

Top Contributors

[![hichxm](https://avatars.githubusercontent.com/u/12587585?v=4)](https://github.com/hichxm "hichxm (23 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-schedule-monitor

Monitor scheduled tasks in a Laravel app

9815.7M9](/packages/spatie-laravel-schedule-monitor)[ashallendesign/short-url

A Laravel package for creating shortened URLs for your web apps.

1.4k1.9M4](/packages/ashallendesign-short-url)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[laracraft-tech/laravel-useful-additions

A collection of useful Laravel additions!

58109.4k](/packages/laracraft-tech-laravel-useful-additions)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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