|
|
@@ -10,6 +10,9 @@ use Dcat\Admin\Show;
|
|
|
use UCore\DcatAdmin\AdminController;
|
|
|
use Dcat\Admin\Layout\Content;
|
|
|
use Spatie\RouteAttributes\Attributes\Resource;
|
|
|
+use UCore\DcatAdmin\FilterHelper;
|
|
|
+use UCore\DcatAdmin\GridHelper;
|
|
|
+use UCore\DcatAdmin\ShowHelper;
|
|
|
|
|
|
#[Resource('game-items-transaction-logs', names: 'dcat.admin.game-items-transaction-logs')]
|
|
|
class TransactionLogController extends AdminController
|
|
|
@@ -36,6 +39,8 @@ class TransactionLogController extends AdminController
|
|
|
protected function grid()
|
|
|
{
|
|
|
return Grid::make(new ItemTransactionLog(), function (Grid $grid) {
|
|
|
+ $helper = new GridHelper($grid, $this);
|
|
|
+
|
|
|
// 禁用创建、编辑和删除按钮
|
|
|
$grid->disableCreateButton();
|
|
|
$grid->disableActions();
|
|
|
@@ -50,32 +55,33 @@ class TransactionLogController extends AdminController
|
|
|
$actions->disableQuickEdit();
|
|
|
});
|
|
|
|
|
|
- $grid->column('id', 'ID')->sortable();
|
|
|
- $grid->column('user_id', '用户ID');
|
|
|
+ $helper->columnId();
|
|
|
+ $helper->column('user_id', '用户ID');
|
|
|
$grid->column('item.name', '物品名称');
|
|
|
- $grid->column('instance_id', '实例ID');
|
|
|
- $grid->column('quantity', '数量');
|
|
|
+ $helper->column('instance_id', '实例ID');
|
|
|
+ $helper->column('quantity', '数量');
|
|
|
$grid->column('transaction_type', '交易类型')->display(function ($value) {
|
|
|
return TRANSACTION_TYPE::getName($value);
|
|
|
});
|
|
|
- $grid->column('source_type', '来源类型');
|
|
|
- $grid->column('source_id', '来源ID');
|
|
|
- $grid->column('expire_at', '过期时间');
|
|
|
- $grid->column('ip_address', 'IP地址');
|
|
|
- $grid->column('created_at', '创建时间')->sortable();
|
|
|
+ $helper->column('source_type', '来源类型');
|
|
|
+ $helper->column('source_id', '来源ID');
|
|
|
+ $helper->column('expire_at', '过期时间');
|
|
|
+ $helper->column('ip_address', 'IP地址');
|
|
|
+ $helper->column('created_at', '创建时间');
|
|
|
|
|
|
// 筛选
|
|
|
$grid->filter(function ($filter) {
|
|
|
- $filter->equal('id', 'ID');
|
|
|
- $filter->equal('user_id', '用户ID');
|
|
|
+ $helper = new FilterHelper($filter, $this);
|
|
|
+ $helper->equal('id', 'ID');
|
|
|
+ $helper->equal('user_id', '用户ID');
|
|
|
$filter->equal('item_id', '物品')->select(
|
|
|
ItemItem::pluck('name', 'id')
|
|
|
);
|
|
|
- $filter->equal('instance_id', '实例ID');
|
|
|
+ $helper->equal('instance_id', '实例ID');
|
|
|
$filter->equal('transaction_type', '交易类型')->select(TRANSACTION_TYPE::all());
|
|
|
- $filter->like('source_type', '来源类型');
|
|
|
- $filter->equal('source_id', '来源ID');
|
|
|
- $filter->between('created_at', '创建时间')->datetime();
|
|
|
+ $helper->like('source_type', '来源类型');
|
|
|
+ $helper->equal('source_id', '来源ID');
|
|
|
+ $helper->between('created_at', '创建时间')->datetime();
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
@@ -104,22 +110,24 @@ class TransactionLogController extends AdminController
|
|
|
protected function detail($id)
|
|
|
{
|
|
|
return Show::make(ItemTransactionLog::findOrFail($id), function (Show $show) {
|
|
|
+ $helper = new ShowHelper($show, $this);
|
|
|
+
|
|
|
// 禁用编辑和删除按钮
|
|
|
$show->panel()->tools(function ($tools) {
|
|
|
$tools->disableEdit();
|
|
|
$tools->disableDelete();
|
|
|
});
|
|
|
|
|
|
- $show->field('id', 'ID');
|
|
|
- $show->field('user_id', '用户ID');
|
|
|
+ $helper->field('id', 'ID');
|
|
|
+ $helper->field('user_id', '用户ID');
|
|
|
$show->field('item.name', '物品名称');
|
|
|
- $show->field('instance_id', '实例ID');
|
|
|
- $show->field('quantity', '数量');
|
|
|
+ $helper->field('instance_id', '实例ID');
|
|
|
+ $helper->field('quantity', '数量');
|
|
|
$show->field('transaction_type', '交易类型')->as(function ($value) {
|
|
|
return TRANSACTION_TYPE::getName($value);
|
|
|
});
|
|
|
- $show->field('source_type', '来源类型');
|
|
|
- $show->field('source_id', '来源ID');
|
|
|
+ $helper->field('source_type', '来源类型');
|
|
|
+ $helper->field('source_id', '来源ID');
|
|
|
|
|
|
// 显示详细信息
|
|
|
$show->field('details', '详细信息')->as(function ($details) {
|
|
|
@@ -151,11 +159,11 @@ class TransactionLogController extends AdminController
|
|
|
return $details;
|
|
|
})->unescape();
|
|
|
|
|
|
- $show->field('expire_at', '过期时间');
|
|
|
- $show->field('ip_address', 'IP地址');
|
|
|
- $show->field('device_info', '设备信息');
|
|
|
- $show->field('created_at', '创建时间');
|
|
|
- $show->field('updated_at', '更新时间');
|
|
|
+ $helper->field('expire_at', '过期时间');
|
|
|
+ $helper->field('ip_address', 'IP地址');
|
|
|
+ $helper->field('device_info', '设备信息');
|
|
|
+ $helper->field('created_at', '创建时间');
|
|
|
+ $helper->field('updated_at', '更新时间');
|
|
|
});
|
|
|
}
|
|
|
}
|