disableCreateButton(); $grid->disableActions(); $grid->disableBatchDelete(); $grid->disableDeleteButton(); $grid->disableEditButton(); // 只保留详情按钮 $grid->actions(function (Grid\Displayers\Actions $actions) { $actions->disableDelete(); $actions->disableEdit(); $actions->disableQuickEdit(); }); $helper->columnId(); $grid->column('user_id', '用户ID'); $grid->column('chest.name', '宝箱名称'); $grid->column('quantity', '开启数量'); $grid->column('pity_triggered', '触发保底')->switch(); $grid->column('pity_content_id', '保底内容ID'); $grid->column('open_time', '开启时间')->sortable(); $grid->column('ip_address', 'IP地址'); $grid->column('created_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') ); $filter->equal('pity_triggered', '触发保底')->radio([ 1 => '是', 0 => '否', ]); $filter->between('open_time', '开启时间')->datetime(); }); }); } /** * 详情页 * * @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 ItemChestOpenLogRepository(), function (Show $show) { $helper = new ShowHelper($show, $this); // 禁用编辑和删除按钮 $show->panel()->tools(function ($tools) { $tools->disableEdit(); $tools->disableDelete(); }); $helper->field('id', 'ID'); $helper->field('user_id', '用户ID'); $show->field('chest.name', '宝箱名称'); $helper->field('quantity', '开启数量'); $helper->field('pity_triggered', '触发保底')->as(function ($value) { return $value ? '是' : '否'; }); $helper->field('pity_content_id', '保底内容ID'); // 显示开箱结果 $show->field('results', '开箱结果')->as(function ($results) { if (empty($results)) { return '无'; } if (is_string($results)) { $results = json_decode($results, true); } if (is_array($results)) { $html = ''; foreach ($results as $index => $chestResult) { $html .= '

第' . ($index + 1) . '次开箱

'; $html .= ''; $html .= ''; $html .= ''; foreach ($chestResult as $item) { $itemInfo = (new ItemRepository())->find($item['item_id']); $itemName = $itemInfo ? $itemInfo->name : '未知物品'; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; } $html .= '
物品ID数量是否保底
' . $item['item_id'] . ' (' . $itemName . ')' . $item['quantity'] . '' . (isset($item['is_pity']) && $item['is_pity'] ? '是' : '否') . '
'; } return $html; } return $results; })->unescape(); $helper->field('open_time', '开启时间'); $helper->field('ip_address', 'IP地址'); $helper->field('device_info', '设备信息'); $helper->field('created_at', '创建时间'); }); } }