1、 复选框
$grid->filter(function ($filter) {
$filter->in('floor', '所在楼层')->checkbox([
1 => "中楼层", 2 => "高楼层", 3 => "低楼层", 4 => "地下室", 5 => "底层", 6 => "顶层", 0 => "暂无数据"
]);
});
2、 筛选范围
$grid->price('单价')->filter('range');
$grid->house_date('更新时间')->filter('range', 'datetime');//筛选范围
3、 排序
$grid->price('单价')->sortable();
4、 布尔值显示
$grid->elevator('配备电梯')->bool(); //布尔值 显示为✓和✗
5、显示转换
$grid->floor('所在楼层')->display(function ($floor) {
$floor_conf = [1 => "中楼层", 2 => "高楼层", 5 => "底层", 6 => "顶层"];
return $floor_conf[$floor];
});
6、 规格选择器
$grid->selector(function (Grid\Tools\Selector $selector) {
$selector->select('floor', '所在楼层', [1 => "中楼层", 2 => "高楼层", 3 => "低楼层", 4 => "地下室", 5 => "底层", 6 => "顶层", 0 => "暂无数据"]);
$selector->select('price', '价格', ['0-999', '1000-1999', '2000-2999'], function ($query, $value) {
$between = [
[0, 999],
[1000, 1999],
[2000, 2999],
];
$query->whereBetween('price', $between[$value[0]]);
});
});