/dcat-orderable

dcat-admin column extension form orderable

Primary LanguagePHP

Dcat Admin Extension

Dcat Admin Extension

演示地址

demo: http://dcat.weiwait.cn (admin:admin)

通过 composer 安装扩展

  composer require weiwait/dcat-orderable

更新 dcat-admin ide-helper

  php artisan admin:ide-helper
// 升序
$grid->model()->orderBy('order');
$grid->column('order')->sequencable();
class Model implements \Spatie\EloquentSortable\Sortable
{
    use \Weiwait\DcatOrderable\SortableTrait

    protected array $sortable = [
        'order_column_name' => 'order',
        // alias: 'column' => 'order'
        'sort_when_creating' => true, // default
        // alias: 'sortable' => true
    ]
}
// 降序
$grid->model()->orderByDesc('order');
$grid->column('order')->sequencable();

class Model implements \Spatie\EloquentSortable\Sortable
{
    use \Weiwait\DcatOrderable\SortableTrait
    
    protected array $sortable = [
        'order_column_name' => 'order',
        // alias: 'column' => 'order'
        'sort_when_creating' => true, // default
        // alias: 'sortable' => true
        'direction' => 'desc' // when using descend method is required
    ]
}

// 分组排序
// 一般场景:二级分类排序、商品根据分类排序...
$grid->model()->orderByDesc('order');
if (request('parent_id')) {
    $grid->column('order')->sequencable();
}
$grid->filter(function ($filter) {
    $filter->equal('parent_id')
        ->select([...$options])
})

class Model implements \Spatie\EloquentSortable\Sortable
{
    use \Weiwait\DcatOrderable\SortableTrait

    // an attribute of this model
    protected $parent_id;

    protected array $sortable = [
        'order_column_name' => 'order',
        // alias: 'column' => 'order'
        'sort_when_creating' => true, // default
        // alias: 'sortable' => true
        'direction' => 'desc' // when using descend method is required
        'restiction' => 'parent_id' // where('parent_id', $this->parent_id)
    ]
}

Dcat-admin 扩展列表

  1. 图片裁剪
  2. 区划级联+坐标拾取
  3. smtp快速便捷配置
  4. sms channel 快速便捷配置