DuplicateRewardGroupAction.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Module\Game\AdminControllers\Actions;
  3. use App\Module\Game\Repositorys\GameRewardGroupRepository;
  4. use Dcat\Admin\Grid\RowAction;
  5. use Illuminate\Http\Request;
  6. /**
  7. * 复制奖励组操作
  8. */
  9. class DuplicateRewardGroupAction extends RowAction
  10. {
  11. /**
  12. * 操作按钮标题
  13. *
  14. * @var string
  15. */
  16. protected $title = '<i class="fa fa-copy"></i> 复制';
  17. /**
  18. * 处理请求
  19. *
  20. * @param Request $request
  21. * @return mixed
  22. */
  23. public function handle(Request $request)
  24. {
  25. try {
  26. $id = $this->getKey();
  27. $repository = new GameRewardGroupRepository();
  28. $newGroup = $repository->duplicate($id);
  29. return $this->response()
  30. ->success("已成功复制奖励组 [{$newGroup->name}]")
  31. ->refresh();
  32. } catch (\Exception $e) {
  33. return $this->response()
  34. ->error('复制失败: ' . $e->getMessage());
  35. }
  36. }
  37. /**
  38. * 确认信息
  39. *
  40. * @return array|string|void
  41. */
  42. public function confirm()
  43. {
  44. return ['确定要复制此奖励组吗?', '复制操作将创建一个新的奖励组记录,包括所有奖励项'];
  45. }
  46. }