Dcat Admin 表格排序扩展 
                                                    
                        
                    
                    
  
                    
                    前言
前段时间使用了一下 Dcat Admin 框架,发现没有一款表格排序的插件,则查看 Dcat Admin 扩展开发文档,写了一个非常简单的表格排序扩展.
截图

使用
引入 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));本作品采用《CC 协议》,转载必须注明作者和本文链接
 
           邢闯洋 的个人博客
 邢闯洋 的个人博客
         
             
             
             
             
             
             
             
             
             
                     
                     
            
 
         
             
            
 
             
             
           
           关于 LearnKu
                关于 LearnKu
               
                     
                     
                     粤公网安备 44030502004330号
 粤公网安备 44030502004330号 
 
推荐文章: