xingchuangyang/dcat-admin-sortable

dcat-admin 表格排序插件

Maintainers

Package info

github.com/18310691938/doct-admin-sortable

Homepage

Issues

pkg:composer/xingchuangyang/dcat-admin-sortable

Statistics

Installs: 1 292

Dependents: 0

Suggesters: 0

Stars: 5

v1.0.0 2021-11-07 06:47 UTC

This package is auto-updated.

Last update: 2026-03-07 17:37:10 UTC


README

截图

使用

引入 composer 包

composer require xingchuangyang/dcat-admin-sortable

修改 Model

引入 SortableTrait,并实现 Sortable 接口

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;

class Product extends Model implements Sortable
{
    use SortableTrait;

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

在 Controller 中使用

$grid->column('sort', '排序')->action(\Xcy\DcatAdminSortable\Actions\SortableColumnRow::gen(\App\Models\Product::class));