disableCreateButton(); $grid->disableActions(); $grid->disableBatchDelete(); $grid->disableDeleteButton(); $grid->disableEditButton(); // 只保留详情按钮 $grid->actions(function (Grid\Displayers\Actions $actions) { $actions->disableDelete(); $actions->disableEdit(); $actions->disableQuickEdit(); }); $grid->column('id', 'ID')->sortable(); $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) { $filter->equal('id', 'ID'); $filter->equal('user_id', '用户ID'); $filter->equal('chest_id', '宝箱')->select( ItemItem::where('type', 5)->pluck('name', 'id') ); $filter->equal('pity_triggered', '触发保底')->radio([ 1 => '是', 0 => '否', ]); $filter->between('open_time', '开启时间')->datetime(); }); return $grid; }); } /** * 详情页 * * @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 ItemChestOpenLog(), function (Show $show) { // 禁用编辑和删除按钮 $show->panel()->tools(function ($tools) { $tools->disableEdit(); $tools->disableDelete(); }); $show->field('id', 'ID'); $show->field('user_id', '用户ID'); $show->field('chest.name', '宝箱名称'); $show->field('quantity', '开启数量'); $show->field('pity_triggered', '触发保底')->as(function ($value) { return $value ? '是' : '否'; }); $show->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 .= '
| 物品ID | 数量 | 是否保底 |
|---|---|---|
| ' . $item['item_id'] . ' (' . $itemName . ') | '; $html .= '' . $item['quantity'] . ' | '; $html .= '' . (isset($item['is_pity']) && $item['is_pity'] ? '是' : '否') . ' | '; $html .= '