| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace App\Module\Game\AdminControllers\Actions;
- use App\Module\Game\Repositorys\GameRewardGroupRepository;
- use Dcat\Admin\Grid\RowAction;
- use Illuminate\Http\Request;
- /**
- * 复制奖励组操作
- */
- class DuplicateRewardGroupAction extends RowAction
- {
- /**
- * 操作按钮标题
- *
- * @var string
- */
- protected $title = '<i class="fa fa-copy"></i> 复制';
- /**
- * 处理请求
- *
- * @param Request $request
- * @return mixed
- */
- public function handle(Request $request)
- {
- try {
- $id = $this->getKey();
-
- $repository = new GameRewardGroupRepository();
- $newGroup = $repository->duplicate($id);
-
- return $this->response()
- ->success("已成功复制奖励组 [{$newGroup->name}]")
- ->refresh();
- } catch (\Exception $e) {
- return $this->response()
- ->error('复制失败: ' . $e->getMessage());
- }
- }
- /**
- * 确认信息
- *
- * @return array|string|void
- */
- public function confirm()
- {
- return ['确定要复制此奖励组吗?', '复制操作将创建一个新的奖励组记录,包括所有奖励项'];
- }
- }
|