PHP code example of weiwait-laravel-admin-ext / sorting

1. Go to this page and download the library: Download weiwait-laravel-admin-ext/sorting library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

weiwait-laravel-admin-ext / sorting example snippets


use Illuminate\Database\Eloquent\Model;
use Spatie\EloquentSortable\Sortable;

Class SomeModel extends Model implements Sortable
{
    use \Weiwait\Sorting\SortingTrait;
    public $sortable = [
        // 设定升序降序
        'direciton' => 'asc or desc',
         // 设定排序时根据此字段分组,排序将根据此字限定段累加 (query->where($restriction, this->$restriction))
        'restriction' => 'this field or unset',
    ];
}

public function grid()
{
    $grid->model()->orderBy('order');
    $grid->column('field', 'label')->sorting();
}