|
|
@@ -9,11 +9,12 @@ use App\Module\GameItems\Repositories\ItemChestConfigRepository;
|
|
|
use Dcat\Admin\Form;
|
|
|
use Dcat\Admin\Grid;
|
|
|
use Dcat\Admin\Show;
|
|
|
+use Spatie\RouteAttributes\Attributes\Resource;
|
|
|
use UCore\DcatAdmin\AdminController;
|
|
|
-use UCore\DcatAdmin\Helpers\FilterHelper;
|
|
|
-use UCore\DcatAdmin\Helpers\FormHelper;
|
|
|
-use UCore\DcatAdmin\Helpers\GridHelper;
|
|
|
-use UCore\DcatAdmin\Helpers\ShowHelper;
|
|
|
+use App\Module\GameItems\AdminControllers\Helper\FilterHelper;
|
|
|
+use App\Module\GameItems\AdminControllers\Helper\FormHelper;
|
|
|
+use App\Module\GameItems\AdminControllers\Helper\GridHelper;
|
|
|
+use App\Module\GameItems\AdminControllers\Helper\ShowHelper;
|
|
|
|
|
|
/**
|
|
|
* 宝箱配置控制器
|
|
|
@@ -21,6 +22,7 @@ use UCore\DcatAdmin\Helpers\ShowHelper;
|
|
|
* 路由: /admin/game-items/chest-configs
|
|
|
* 菜单: 游戏管理 -> 物品管理 -> 宝箱配置
|
|
|
*/
|
|
|
+#[Resource('game-items/chest-configs', names: 'dcat.admin.game-items.chest-configs')]
|
|
|
class ItemChestConfigController extends AdminController
|
|
|
{
|
|
|
/**
|
|
|
@@ -52,29 +54,30 @@ class ItemChestConfigController extends AdminController
|
|
|
*/
|
|
|
protected function grid(): Grid
|
|
|
{
|
|
|
- return GridHelper::make(new ItemChestConfig(), function (Grid $grid) {
|
|
|
- $grid->column('id', 'ID')->sortable();
|
|
|
-
|
|
|
+ return Grid::make(new ItemChestConfig(), function (Grid $grid) {
|
|
|
+ $helper = new GridHelper($grid, $this);
|
|
|
+ $helper->columnId();
|
|
|
+
|
|
|
$grid->column('item.name', '宝箱名称')->display(function ($name) {
|
|
|
return $name ?: '未知宝箱';
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
$grid->column('item_id', '宝箱ID')->sortable();
|
|
|
-
|
|
|
+
|
|
|
$grid->column('consume_group.name', '消耗组')->display(function ($name) {
|
|
|
return $name ?: '<span class="text-muted">无消耗</span>';
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
$grid->column('reward_group.name', '奖励组')->display(function ($name) {
|
|
|
return $name ?: '<span class="text-danger">未配置</span>';
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
$grid->column('condition_group.name', '条件组')->display(function ($name) {
|
|
|
return $name ?: '<span class="text-muted">无条件</span>';
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
$grid->column('is_active', '状态')->switch();
|
|
|
-
|
|
|
+
|
|
|
$grid->column('status_text', '配置状态')->display(function () {
|
|
|
return $this->status_text;
|
|
|
})->label([
|
|
|
@@ -82,14 +85,14 @@ class ItemChestConfigController extends AdminController
|
|
|
'未激活' => 'warning',
|
|
|
'缺少奖励组' => 'danger',
|
|
|
]);
|
|
|
-
|
|
|
- $grid->column('created_at', '创建时间')->sortable();
|
|
|
- $grid->column('updated_at', '更新时间')->sortable();
|
|
|
+
|
|
|
+ $helper->columnCreatedAt();
|
|
|
+ $helper->columnUpdatedAt();
|
|
|
|
|
|
// 筛选器
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
|
- FilterHelper::defaultDateRange($filter);
|
|
|
-
|
|
|
+ $filterHelper = new FilterHelper($filter, $this);
|
|
|
+
|
|
|
$filter->equal('item_id', '宝箱ID');
|
|
|
$filter->like('item.name', '宝箱名称');
|
|
|
$filter->equal('consume_group_id', '消耗组')->select(\App\Module\Game\Models\GameConsumeGroup::pluck('name', 'id'));
|
|
|
@@ -121,33 +124,34 @@ class ItemChestConfigController extends AdminController
|
|
|
*/
|
|
|
protected function detail($id): Show
|
|
|
{
|
|
|
- return ShowHelper::make($id, new ItemChestConfig(), function (Show $show) {
|
|
|
- $show->field('id', 'ID');
|
|
|
+ return Show::make($id, new ItemChestConfig(), function (Show $show) {
|
|
|
+ $helper = new ShowHelper($show, $this);
|
|
|
+ $helper->field('id', 'ID');
|
|
|
$show->field('item.name', '宝箱名称');
|
|
|
$show->field('item_id', '宝箱ID');
|
|
|
-
|
|
|
+
|
|
|
$show->divider('消耗组配置');
|
|
|
$show->field('consume_group.name', '消耗组名称');
|
|
|
$show->field('consume_group.code', '消耗组编码');
|
|
|
$show->field('consume_group.description', '消耗组描述');
|
|
|
-
|
|
|
+
|
|
|
$show->divider('奖励组配置');
|
|
|
$show->field('reward_group.name', '奖励组名称');
|
|
|
$show->field('reward_group.code', '奖励组编码');
|
|
|
$show->field('reward_group.description', '奖励组描述');
|
|
|
$show->field('reward_group.is_random', '是否随机')->using([0 => '否', 1 => '是']);
|
|
|
$show->field('reward_group.random_count', '随机数量');
|
|
|
-
|
|
|
+
|
|
|
$show->divider('条件组配置');
|
|
|
$show->field('condition_group.name', '条件组名称');
|
|
|
$show->field('condition_group.code', '条件组编码');
|
|
|
$show->field('condition_group.description', '条件组描述');
|
|
|
-
|
|
|
+
|
|
|
$show->divider('基本信息');
|
|
|
$show->field('is_active', '状态')->using([0 => '未激活', 1 => '激活']);
|
|
|
$show->field('status_text', '配置状态');
|
|
|
- $show->field('created_at', '创建时间');
|
|
|
- $show->field('updated_at', '更新时间');
|
|
|
+ $helper->field('created_at', '创建时间');
|
|
|
+ $helper->field('updated_at', '更新时间');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -158,7 +162,8 @@ class ItemChestConfigController extends AdminController
|
|
|
*/
|
|
|
protected function form(): Form
|
|
|
{
|
|
|
- return FormHelper::make(new ItemChestConfig(), function (Form $form) {
|
|
|
+ return Form::make(new ItemChestConfig(), function (Form $form) {
|
|
|
+ $helper = new FormHelper($form, $this);
|
|
|
$form->display('id', 'ID');
|
|
|
|
|
|
$form->select('item_id', '宝箱物品')
|