|
|
@@ -13,6 +13,7 @@ use Spatie\RouteAttributes\Attributes\Resource;
|
|
|
#[Resource('game-items-chest-open-logs', names: 'dcat.admin.game-items-chest-open-logs')]
|
|
|
class ChestOpenLogController extends AdminController
|
|
|
{
|
|
|
+
|
|
|
/**
|
|
|
* 标题
|
|
|
*
|
|
|
@@ -34,47 +35,48 @@ class ChestOpenLogController extends AdminController
|
|
|
*/
|
|
|
protected function grid()
|
|
|
{
|
|
|
- $grid = new Grid(new ItemChestOpenLog());
|
|
|
-
|
|
|
- // 禁用创建、编辑和删除按钮
|
|
|
- $grid->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::make(new ItemChestOpenLog(), function (Grid $grid) {
|
|
|
+
|
|
|
+ // 禁用创建、编辑和删除按钮
|
|
|
+ $grid->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;
|
|
|
});
|
|
|
-
|
|
|
- return $grid;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -100,67 +102,69 @@ class ChestOpenLogController extends AdminController
|
|
|
*/
|
|
|
protected function detail($id)
|
|
|
{
|
|
|
- $show = new Show(ItemChestOpenLog::findOrFail($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 '无';
|
|
|
+ }
|
|
|
|
|
|
- // 禁用编辑和删除按钮
|
|
|
- $show->panel()->tools(function ($tools) {
|
|
|
- $tools->disableEdit();
|
|
|
- $tools->disableDelete();
|
|
|
- });
|
|
|
+ if (is_string($results)) {
|
|
|
+ $results = json_decode($results, true);
|
|
|
+ }
|
|
|
|
|
|
- $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 .= '<h4>第' . ($index + 1) . '次开箱</h4>';
|
|
|
- $html .= '<table class="table table-bordered">';
|
|
|
- $html .= '<thead><tr><th>物品ID</th><th>数量</th><th>是否保底</th></tr></thead>';
|
|
|
- $html .= '<tbody>';
|
|
|
-
|
|
|
- foreach ($chestResult as $item) {
|
|
|
- $itemInfo = ItemItem::find($item['item_id']);
|
|
|
- $itemName = $itemInfo ? $itemInfo->name : '未知物品';
|
|
|
-
|
|
|
- $html .= '<tr>';
|
|
|
- $html .= '<td>' . $item['item_id'] . ' (' . $itemName . ')</td>';
|
|
|
- $html .= '<td>' . $item['quantity'] . '</td>';
|
|
|
- $html .= '<td>' . (isset($item['is_pity']) && $item['is_pity'] ? '是' : '否') . '</td>';
|
|
|
- $html .= '</tr>';
|
|
|
+ if (is_array($results)) {
|
|
|
+ $html = '';
|
|
|
+
|
|
|
+ foreach ($results as $index => $chestResult) {
|
|
|
+ $html .= '<h4>第' . ($index + 1) . '次开箱</h4>';
|
|
|
+ $html .= '<table class="table table-bordered">';
|
|
|
+ $html .= '<thead><tr><th>物品ID</th><th>数量</th><th>是否保底</th></tr></thead>';
|
|
|
+ $html .= '<tbody>';
|
|
|
+
|
|
|
+ foreach ($chestResult as $item) {
|
|
|
+ $itemInfo = ItemItem::find($item['item_id']);
|
|
|
+ $itemName = $itemInfo ? $itemInfo->name : '未知物品';
|
|
|
+
|
|
|
+ $html .= '<tr>';
|
|
|
+ $html .= '<td>' . $item['item_id'] . ' (' . $itemName . ')</td>';
|
|
|
+ $html .= '<td>' . $item['quantity'] . '</td>';
|
|
|
+ $html .= '<td>' . (isset($item['is_pity']) && $item['is_pity'] ? '是' : '否') . '</td>';
|
|
|
+ $html .= '</tr>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $html .= '</tbody></table>';
|
|
|
}
|
|
|
|
|
|
- $html .= '</tbody></table>';
|
|
|
+ return $html;
|
|
|
}
|
|
|
|
|
|
- return $html;
|
|
|
- }
|
|
|
+ return $results;
|
|
|
+ })->unescape();
|
|
|
|
|
|
- return $results;
|
|
|
- })->unescape();
|
|
|
+ $show->field('open_time', '开启时间');
|
|
|
+ $show->field('ip_address', 'IP地址');
|
|
|
+ $show->field('device_info', '设备信息');
|
|
|
+ $show->field('created_at', '创建时间');
|
|
|
|
|
|
- $show->field('open_time', '开启时间');
|
|
|
- $show->field('ip_address', 'IP地址');
|
|
|
- $show->field('device_info', '设备信息');
|
|
|
- $show->field('created_at', '创建时间');
|
|
|
-
|
|
|
- return $show;
|
|
|
+ return $show;
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
}
|