james.xue / laravel-admin-sortable
Sortable behaviour for eloquent models
Fund package maintenance!
james.dmzfa.com/about#pay
Installs: 7 352
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: >=7.0.0
- encore/laravel-admin: ~1.6
- james.xue/laravel-sortable: ~1.1
- laravel/framework: >= 5.4
Requires (Dev)
- phpunit/phpunit: ~6.0
This package is auto-updated.
Last update: 2024-11-07 18:13:08 UTC
README
这个扩展包用来 sortable
Screenshot
Installation First, install dependencies:
composer require james.xue/laravel-admin-sortable
Second, Modified model
use James\Sortable\SortableTrait;
use James\Sortable\Sortable;
class Test extends Model implements Sortable
{
use SortableTrait;
public $sortable = [
'sort_field' => 'status', // 排序字段
'sort_when_creating' => true, // 新增是否自增,默认自增
];
}
Configuration In the extensions section of the config/admin.php file, add some configuration that belongs to this extension.
'extensions' => [
'sortableColumn' => [
// set to false if you want to disable this extension
'enable' => true,
]
]
User
$grid = new Grid(new Test);
$grid->model()->orderBy('status', 'asc'); // 这个很重要,否则页面显示顺序不正确
$grid->status('状态')->sortableColumn('\App\Test'); // sortableColumn 里面必须填入当前模型的 namespace ,
OR
$grid->status('状态')->sortableColumn(Test::class);