PHPackages                             atomcoder/laravel-reorderable - 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. atomcoder/laravel-reorderable

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

atomcoder/laravel-reorderable
=============================

Drag and drop reorder functionality for Laravel Eloquent models.

1.0.0(1mo ago)389↓62.5%1MITPHPPHP ^8.3

Since Apr 12Pushed 1w ago1 watchersCompare

[ Source](https://github.com/RichieMcMullen/laravel-reorderable)[ Packagist](https://packagist.org/packages/atomcoder/laravel-reorderable)[ RSS](/packages/atomcoder-laravel-reorderable/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

Laravel Reorderable
===================

[](#laravel-reorderable)

[![Laravel Reorderable](docs/images/header.png)](docs/images/header.png)

Drag-and-drop sorting for Laravel Eloquent models, with both Blade and Livewire UI support.

What This Package Does
----------------------

[](#what-this-package-does)

This package lets you:

- store a sortable position on any Eloquent model
- render a drag-and-drop list in Blade or Livewire
- persist the new order automatically through a package route
- reorder items inside a group such as `project_id`, `board_id`, or `category_id`
- reorder items programmatically in PHP
- listen for an event when items are reordered

If you have records like tasks, posts, sections, menu items, images, or lessons, this package gives you a clean way to let users reorder them.

Requirements
------------

[](#requirements)

- PHP `^8.3`
- Laravel `^13.0`
- Livewire `^4.0`

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

[](#installation)

```
composer require atomcoder/laravel-reorderable
php artisan reorderable:install
```

The install command publishes:

- `config/reorderable.php`
- package views
- the migration stub used by the generator command

After installing, the usual setup is:

1. add a sort column to your table
2. add the trait to your model
3. add your model to `allowed_models`
4. load records using the `ordered()` scope
5. render the Blade include or Livewire component

Quick Start
-----------

[](#quick-start)

### 1. Add a sort column to your table

[](#1-add-a-sort-column-to-your-table)

By default, the package uses a column named `sort_order`.

```
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Schema::table('tasks', function (Blueprint $table) {
    $table->unsignedInteger('sort_order')->default(0)->index();
});
```

If you want a different column name such as `position`, that is fine. You will just need to tell the model which column to use.

### 2. Make your model reorderable

[](#2-make-your-model-reorderable)

```
