PHPackages                             lartisan/laravel-sortable-medialibrary - 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. [Image &amp; Media](/categories/media)
4. /
5. lartisan/laravel-sortable-medialibrary

ActiveLibrary[Image &amp; Media](/categories/media)

lartisan/laravel-sortable-medialibrary
======================================

Associate files with Eloquent models and add Sortable behaviour

9.4.2(5y ago)010MITPHPPHP ^7.4|^8.0

Since Apr 22Pushed 5y agoCompare

[ Source](https://github.com/lartisan/laravel-sortable-medialibrary)[ Packagist](https://packagist.org/packages/lartisan/laravel-sortable-medialibrary)[ Docs](https://github.com/spatie/laravel-medialibrary)[ Fund](https://spatie.be/open-source/support-us)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/lartisan-laravel-sortable-medialibrary/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (19)Versions (325)Used By (0)

[![](art/lartisan_logo.png)](art/lartisan_logo.png)

[![Total Downloads](https://camo.githubusercontent.com/20475dad22db886f20a4c9213413dfe28c1daafd62b123e60f12863ed382ec2d/68747470733a2f2f706f7365722e707567782e6f72672f6c6172746973616e2f6c61726176656c2d736f727461626c652d6d656469616c6962726172792f642f746f74616c2e737667)](https://packagist.org/packages/lartisan/laravel-sortable-medialibrary)[![Latest Stable Version](https://camo.githubusercontent.com/12a5b90a9a84cbac232e7c830c9f39d6d89b4f96117f6c982dac48e590283971/68747470733a2f2f706f7365722e707567782e6f72672f6c6172746973616e2f6c61726176656c2d736f727461626c652d6d656469616c6962726172792f762f737461626c652e737667)](https://packagist.org/packages/lartisan/laravel-sortable-medialibrary)[![License](https://camo.githubusercontent.com/73e70595aec59ceae5440b432e2dfbf965c77f855cc0e997646e120d5efc9263/68747470733a2f2f706f7365722e707567782e6f72672f6c6172746973616e2f6c61726176656c2d736f727461626c652d6d656469616c6962726172792f6c6963656e73652e737667)](https://packagist.org/packages/lartisan/laravel-sortable-medialibrary)

---

Changes to the original package
===============================

[](#changes-to-the-original-package)

This forked package eliminates the **IsSorted** Trait from `Spatie\MediaLibrary\MediaCollections\Models\Media`, so the sorting/ordering part could be made by [spatie/eloquent-sortable](https://github.com/spatie/eloquent-sortable). I have also added the `spatie/eloquent-sortable` as a dependency.

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

[](#installation)

This package uses `"spatie/eloquent-sortable": "^3.11"` together with `"spatie/laravel-medialibrary": "^9.0.0"` and it can be installed through Composer:

```
composer require lartisan/laravel-sortable-medialibrary
```

In Laravel 5.5 and above the service provider will automatically get registered. In older versions of the framework just add the service provider in config/app.php file:

```
'providers' => [
    ...
    Spatie\MediaLibrary\MediaLibraryServiceProvider::class,
    Spatie\EloquentSortable\EloquentSortableServiceProvider::class,
];
```

Optionally you can publish the config files with:

```
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="migrations"
php artisan vendor:publish --provider="Spatie\EloquentSortable\EloquentSortableServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

#### To add the intended Eloquent sortable behaviour to your custom Media model you must:

[](#to-add-the-intended-eloquent-sortable-behaviour-to-your-custom-media-model-you-must)

1. Implement the `Spatie\EloquentSortable\Sortable` interface.
2. Use the trait `Spatie\EloquentSortable\SortableTrait`.
3. Optionally specify which column will be used as the order column. The default is `order_column`.
4. Optionally, if your model/table has a grouping field, you can create a `buildSortQuery` method at your model.

Example:

```
...
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;
use Spatie\MediaLibrary\MediaCollections\Models\Media as BaseMedia;

class MyCustomMedia extends BaseMedia implements Sortable
{
    use SortableTrait;

    /**
     * Define the column used for sorting
     * @var array
     */
    public $sortable = [
        'order_column_name' => 'order_column',
        'sort_when_creating' => true,
    ];

    /**
     * @return Builder
     */
    public function buildSortQuery(): Builder
    {
        return static::query()
            ->where('collection_name', $this->collection_name);
    }
    ...
}
```

#### To add the default sort of the original package behaviour to your custom Media model

[](#to-add-the-default-sort-of-the-original-package-behaviour-to-your-custom-media-model)

You could still use the default **IsSorted** behaviour of the original package by adding the `Spatie\MediaLibrary\MediaCollections\Models\Concerns\IsSorted` to your model.

Example:

```
...
use Spatie\MediaLibrary\MediaCollections\Models\Concerns\IsSorted;
use Spatie\MediaLibrary\MediaCollections\Models\Media as BaseMedia;

class MyCustomMedia extends BaseMedia
{
    use IsSorted;
}
```

Documentation
-------------

[](#documentation)

The original [spatie/laravel-medialibrary](https://docs.spatie.be/laravel-medialibrary/v8) package.

The [spatie/eloquent-sortable](https://github.com/spatie/eloquent-sortable) package.

License
-------

[](#license)

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

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 80.8% 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 ~6 days

Recently: every ~17 days

Total

324

Last Release

1917d ago

Major Versions

7.19.3 → 8.0.02020-03-09

7.19.4 → 8.8.02020-09-30

8.10.1 → 9.0.02020-10-30

v7.x-dev → 9.1.12020-11-06

v8.x-dev → 9.3.02020-11-30

PHP version history (8 changes)0.1.0PHP &gt;=5.4.0

2.0.0PHP &gt;=5.5.0

3.12.0PHP ^5.5|^7.0

4.0.0PHP ^7.0

7.0.0PHP ^7.1

7.6.0PHP ^7.2

8.0.0PHP ^7.4

9.0.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2dcd7882a854e97effa9fbf7c979e9c9c7f9795bfb5422224a22253a10fd0cc0?d=identicon)[cristake](/maintainers/cristake)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (1309 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (69 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (66 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (32 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (27 commits)")[![MatthiasDeWinter](https://avatars.githubusercontent.com/u/8791525?v=4)](https://github.com/MatthiasDeWinter "MatthiasDeWinter (25 commits)")[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (12 commits)")[![ahmedofali](https://avatars.githubusercontent.com/u/22732463?v=4)](https://github.com/ahmedofali "ahmedofali (8 commits)")[![arubacao](https://avatars.githubusercontent.com/u/7462542?v=4)](https://github.com/arubacao "arubacao (7 commits)")[![nicolasbeauvais](https://avatars.githubusercontent.com/u/2951704?v=4)](https://github.com/nicolasbeauvais "nicolasbeauvais (5 commits)")[![willemvb](https://avatars.githubusercontent.com/u/1336390?v=4)](https://github.com/willemvb "willemvb (4 commits)")[![antonkomarev](https://avatars.githubusercontent.com/u/1849174?v=4)](https://github.com/antonkomarev "antonkomarev (4 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (4 commits)")[![Firtzberg](https://avatars.githubusercontent.com/u/8490119?v=4)](https://github.com/Firtzberg "Firtzberg (4 commits)")[![gdebrauwer](https://avatars.githubusercontent.com/u/22586858?v=4)](https://github.com/gdebrauwer "gdebrauwer (4 commits)")[![francoism90](https://avatars.githubusercontent.com/u/5028905?v=4)](https://github.com/francoism90 "francoism90 (3 commits)")[![Omranic](https://avatars.githubusercontent.com/u/406705?v=4)](https://github.com/Omranic "Omranic (3 commits)")[![Rhincodon](https://avatars.githubusercontent.com/u/6630959?v=4)](https://github.com/Rhincodon "Rhincodon (3 commits)")[![canvural](https://avatars.githubusercontent.com/u/1574232?v=4)](https://github.com/canvural "canvural (3 commits)")[![TVke](https://avatars.githubusercontent.com/u/15680337?v=4)](https://github.com/TVke "TVke (3 commits)")

---

Tags

spatielaravelconversionimagesmediacmsdownloadslaravel-medialibrary

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.1k37.7M472](/packages/spatie-laravel-medialibrary)[okipa/laravel-medialibrary-ext

Extra features for spatie/laravel-medialibrary package.

1011.2k](/packages/okipa-laravel-medialibrary-ext)[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)
