ViewChestDetailAction.php 986 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Module\GameItems\AdminControllers\Actions;
  3. use App\Module\GameItems\Models\ItemChestContent;
  4. use Illuminate\Http\Request;
  5. use UCore\DcatAdmin\RowActionHandler;
  6. /**
  7. * 查看宝箱详情
  8. *
  9. * 在宝箱内容管理行中添加查看宝箱详情的快捷操作
  10. */
  11. class ViewChestDetailAction extends RowActionHandler
  12. {
  13. /**
  14. * 操作按钮标题
  15. *
  16. * @var string
  17. */
  18. public $title = '宝箱详情';
  19. /**
  20. * 处理请求
  21. *
  22. * @param Request $request
  23. * @return mixed
  24. */
  25. public function handle(Request $request)
  26. {
  27. $id = $this->getKey();
  28. $content = ItemChestContent::with('chest')->find($id);
  29. if (!$content || !$content->chest_id) {
  30. return $this->response()->error('宝箱不存在');
  31. }
  32. // 跳转到宝箱详情页面
  33. return $this->response()->redirect(
  34. admin_url("game-items/{$content->chest_id}")
  35. );
  36. }
  37. }