xingchuangyang/dcat-admin-sortable

dcat-admin 表格排序插件

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

This package is auto-updated.

Last update: 2024-04-07 13:12:21 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));