james.xue/laravel-admin-sortable

Sortable behaviour for eloquent models
7,875 7
Install
composer require james.xue/laravel-admin-sortable
Latest Version:1.0
PHP:>=7.0.0
License:MIT
Last Updated:Jul 23, 2026
Links: GitHub  ·  Packagist
Maintainer: xiaoxuan6

这个扩展包用来 sortable

Screenshot

screenshot

Installation First, install dependencies:

composer require james.xue/laravel-admin-sortable

Second, Modified model

use James\Sortable\SortableTrait;
use James\Sortable\Sortable;

class Test extends Model implements Sortable
{
    use SortableTrait;

    public $sortable = [
        'sort_field' => 'status',       // 排序字段
        'sort_when_creating' => true,   // 新增是否自增,默认自增
    ];

}

Configuration In the extensions section of the config/admin.php file, add some configuration that belongs to this extension.

 'extensions' => [
     'sortableColumn' => [
         // set to false if you want to disable this extension
         'enable' => true,
     ]
 ]

User

   $grid = new Grid(new Test);
   $grid->model()->orderBy('status', 'asc');            // 这个很重要,否则页面显示顺序不正确

   $grid->status('状态')->sortableColumn('\App\Test');  // sortableColumn 里面必须填入当前模型的 namespace ,
   OR
   $grid->status('状态')->sortableColumn(Test::class);

Related Packages

johankladder/eloquent-sortable

Sortable behaviour for eloquent models

1,089 0
ittest-dev/eloquent-sortable

Sortable behaviour for eloquent models

10,249 0
spatie/eloquent-sortable

Sortable behaviour for eloquent models

28,439,319 1,518
jedrzej/pimpable

Laravel 4/5/6 package that allows to dynamically filter, sort and eager load rel...

193,442 104
jedrzej/sortable

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

291,468 52