column('id', 'ID')->sortable(); $grid->column('user_id', '用户ID')->sortable(); $grid->column('shopItem.name', '商品名称'); $grid->column('item.name', '物品名称'); $grid->column('quantity', '购买数量'); $grid->column('price', '单价'); $grid->column('total_price', '总价'); $grid->column('currency_id', '货币类型')->display(function ($currencyId) { $currency = Currency::find($currencyId); return $currency ? $currency->name : '未知'; }); $grid->column('purchase_time', '购买时间')->sortable(); $grid->column('ip_address', 'IP地址'); $grid->column('created_at', '创建时间')->sortable(); // 过滤器 $grid->filter(function (Grid\Filter $filter) { $filter->equal('id', 'ID'); $filter->equal('user_id', '用户ID'); $filter->equal('shop_item_id', '商品')->select( ShopItem::pluck('name', 'id') ); $filter->equal('item_id', '物品')->select( Item::pluck('name', 'id') ); $filter->equal('currency_id', '货币类型')->select( Currency::pluck('name', 'id') ); $filter->between('purchase_time', '购买时间')->datetime(); $filter->like('ip_address', 'IP地址'); }); // 工具栏 $grid->disableCreateButton(); $grid->disableEditButton(); $grid->disableDeleteButton(); $grid->toolsWithOutline(false); $grid->showQuickEditButton(false); }); } /** * 创建详情页 * * @param mixed $id * @return Show */ protected function detail($id) { return Show::make($id, new ShopPurchaseLogRepository(), function (Show $show) { $show->field('id', 'ID'); $show->field('user_id', '用户ID'); $show->field('shopItem.name', '商品名称'); $show->field('item.name', '物品名称'); $show->field('quantity', '购买数量'); $show->field('price', '单价'); $show->field('total_price', '总价'); $show->field('currency_id', '货币类型')->as(function ($currencyId) { $currency = Currency::find($currencyId); return $currency ? $currency->name : '未知'; }); $show->field('purchase_time', '购买时间'); $show->field('ip_address', 'IP地址'); $show->field('device_info', '设备信息'); $show->field('created_at', '创建时间'); $show->field('updated_at', '更新时间'); $show->disableEditButton(); $show->disableDeleteButton(); }); } }