讨论数量:
这个应该是hasMany的关系,可以使用withCount整合成新的字段,这个字段就可以排序了
return Grid::make(
ParentModel::withCount([
'post as one',
'post as two'=>function(Builder $builder){
$builder->where('status','ED');
},
'post as three'=>function(){
},
...
])
, function (Grid $grid) {
$grid->column('one', 'one_label')->sortable();
$grid->column('two', 'two_label')->sortable();
$grid->column('three', 'three_label')->sortable();
...
});
推荐文章: