|
|
@@ -42,19 +42,23 @@ class ItemChestOpenCostController extends AdminController
|
|
|
|
|
|
$helper->columnId();
|
|
|
$grid->column('chest.name', '宝箱名称')->link(function () {
|
|
|
- return admin_url('game-items/items/' . $this->chest_id);
|
|
|
+ return admin_url('game-items/' . $this->chest_id);
|
|
|
});
|
|
|
|
|
|
$grid->column('cost_type', '消耗类型')->display(function ($value) {
|
|
|
return CHEST_COST_TYPE::getAll()[$value] ?? '未知';
|
|
|
});
|
|
|
|
|
|
- $grid->column('cost_id', '消耗ID')->display(function ($value) {
|
|
|
+ $grid->column('cost_id', '消耗ID')->as(function ($value) {
|
|
|
if ($this->cost_type == CHEST_COST_TYPE::ITEM->value) {
|
|
|
- return $this->costItem ? "{$this->costItem->name} (ID: {$value})" : $value;
|
|
|
+ if ($this->costItem) {
|
|
|
+ $itemUrl = admin_url('game-items-items/' . $value);
|
|
|
+ return "<a href='{$itemUrl}' target='_blank'>{$this->costItem->name} <i class='fa fa-external-link'></i></a> (ID: {$value})";
|
|
|
+ }
|
|
|
+ return $value;
|
|
|
}
|
|
|
return $value;
|
|
|
- });
|
|
|
+ })->unescape();
|
|
|
|
|
|
$grid->column('cost_quantity', '消耗数量');
|
|
|
$grid->column('is_active', '是否激活')->switch();
|
|
|
@@ -65,14 +69,9 @@ class ItemChestOpenCostController extends AdminController
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
|
$helper = new FilterHelper($filter, $this);
|
|
|
$helper->equal('id', 'ID');
|
|
|
- $filter->equal('chest_id', '宝箱')->select(
|
|
|
- Item::where('type', 3)->pluck('name', 'id')
|
|
|
- );
|
|
|
- $filter->where('chest_name', function ($query) {
|
|
|
- $query->whereHas('chest', function ($query) {
|
|
|
- $query->where('name', 'like', "%{$this->input}%");
|
|
|
- });
|
|
|
- }, '宝箱名称');
|
|
|
+ $helper->equalSelectModelChestItem('chest_id', '宝箱ID');
|
|
|
+
|
|
|
+
|
|
|
$filter->equal('cost_type', '消耗类型')->select(CHEST_COST_TYPE::getAll());
|
|
|
$filter->equal('is_active', '是否激活')->radio([
|
|
|
1 => '是',
|
|
|
@@ -116,7 +115,10 @@ class ItemChestOpenCostController extends AdminController
|
|
|
// 根据消耗类型显示不同的关联信息
|
|
|
$show->field('costItem.name', '消耗物品名称')->unescape()->as(function ($name) {
|
|
|
if ($this->cost_type == CHEST_COST_TYPE::ITEM->value && $name) {
|
|
|
- return "<span class='badge badge-primary'>{$name}</span>";
|
|
|
+ $itemUrl = admin_url('game-items/items/' . $this->cost_id);
|
|
|
+ return "<span class='badge badge-primary'>{$name}</span> "
|
|
|
+ . "<a href='{$itemUrl}' target='_blank' class='btn btn-sm btn-primary ml-1'>"
|
|
|
+ . "<i class='fa fa-external-link'></i> 查看物品详情</a>";
|
|
|
}
|
|
|
return '-';
|
|
|
});
|
|
|
@@ -144,19 +146,11 @@ class ItemChestOpenCostController extends AdminController
|
|
|
// 只显示宝箱类型的物品
|
|
|
$chests = Item::where('type', 3)->pluck('name', 'id');
|
|
|
|
|
|
- $form->select('chest_id', '宝箱')->options($chests)->required();
|
|
|
+ $helper->selectModelChestItem('chest_id', '宝箱');
|
|
|
$form->select('cost_type', '消耗类型')->options(CHEST_COST_TYPE::getAll())->required();
|
|
|
|
|
|
// 根据消耗类型显示不同的选择器
|
|
|
- $form->select('cost_id', '消耗ID')->options(function ($id) {
|
|
|
- $costType = request()->get('cost_type');
|
|
|
-
|
|
|
- if ($costType == CHEST_COST_TYPE::ITEM->value) {
|
|
|
- return Item::pluck('name', 'id');
|
|
|
- }
|
|
|
-
|
|
|
- return [];
|
|
|
- })->required();
|
|
|
+ $form->number('cost_id', '消耗ID')->required();
|
|
|
|
|
|
$helper->number('cost_quantity', '消耗数量')->min(1)->default(1)->required();
|
|
|
$form->switch('is_active', '是否激活')->default(1);
|