xingchuangyang / dcat-admin-sortable
dcat-admin 表格排序插件
v1.0.0
2021-11-07 06:47 UTC
Requires
- php: >=7.1.0
- dcat/laravel-admin: ~2.0
- james.xue/laravel-sortable: ~1.1
This package is auto-updated.
Last update: 2025-04-07 15:18:07 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));