xn/grid-sortable

通过拖动行对网格数据进行排序

v0.0.3 2023-03-16 10:54 UTC

This package is auto-updated.

Last update: 2024-09-16 14:02:17 UTC


README

安装

composer require xn/grid-sortable

使用

定义您的模型

<?php

use Illuminate\Database\Eloquent\Model;
use Spatie\EloquentSortable\Sortable;
use Xn\GridSortable\Traits\SortableTrait;

class MyModel extends Model implements Sortable
{
    use SortableTrait;

    public $sortable = [
        'order_column_name' => 'order_column',
        'sort_when_creating' => true,
        'direction' => 'desc',
    ];
}

在网格中使用

$grid = new Grid(new MyModel);

$grid->sortable();

翻译

按钮的默认文本为 保存顺序。如果您使用其他语言,例如简体中文,您可以在 resources/lang/zh-CN.json 文件中添加翻译。

{
    "Save order": "保存排序"
}

许可证

许可协议为 MIT 许可协议 (MIT)