Giter Site home page Giter Site logo

dcat-orderable's Introduction

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 快速便捷配置

dcat-orderable's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.