disableCreateButton(); $grid->disableActions(); $grid->disableBatchDelete(); $grid->disableDeleteButton(); $grid->disableEditButton(); // 只保留详情按钮 $grid->actions(function (Grid\Displayers\Actions $actions) { $actions->disableDelete(); $actions->disableEdit(); $actions->disableQuickEdit(); }); $helper = new GridHelper($grid, $this); $helper->columnId(); $grid->column('user_id', '用户ID'); $grid->column('chest.name', '宝箱名称'); $grid->column('chest_content_id', '宝箱内容ID'); $grid->column('current_count', '当前计数'); $grid->column('created_at', '创建时间'); $grid->column('updated_at', '更新时间'); // 筛选 $grid->filter(function ($filter) { $helper = new FilterHelper($filter, $this); $helper->equal('id', 'ID'); $helper->equal('user_id', '用户ID'); $filter->equal('chest_id', '宝箱')->select( (new ItemRepository())->where('type', 5)->pluck('name', 'id') ); $helper->equal('chest_content_id', '宝箱内容ID'); $helper->between('current_count', '当前计数'); }); }); } /** * 详情页 * * @param mixed $id * @param Content $content * @return Content */ public function show($id, Content $content) { return $content ->header($this->title) ->description('详情') ->body($this->detail($id)); } /** * 详情页 * * @param mixed $id * @return Show */ protected function detail($id) { return Show::make($id, new ItemPityTimeRepository(), function (Show $show) { // 禁用编辑和删除按钮 $show->panel()->tools(function ($tools) { $tools->disableEdit(); $tools->disableDelete(); }); $helper = new ShowHelper($show, $this); $helper->field('id', 'ID'); $show->field('user_id', '用户ID'); $show->field('chest.name', '宝箱名称'); // 显示宝箱内容信息 $show->field('chest_content_id', '宝箱内容ID'); $show->field('chestContent.item.name', '内容物品名称'); $show->field('chestContent.group.name', '内容物品组名称'); $show->field('chestContent.pity_count', '保底次数'); $show->field('chestContent.pity_weight_factor', '保底权重因子'); $show->field('current_count', '当前计数'); // 计算距离保底还需次数 $show->field('remaining_count', '距离保底还需次数')->as(function () { if (!$this->chestContent || !$this->chestContent->pity_count) { return '无保底机制'; } $remaining = max(0, $this->chestContent->pity_count - $this->current_count); return $remaining; }); $helper->field('created_at', '创建时间'); $helper->field('updated_at', '更新时间'); }); } }