| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace App\Module\GameItems\AdminControllers\Actions;
- use App\Module\GameItems\Repositorys\ItemRepository;
- use Dcat\Admin\Grid\RowAction;
- use Illuminate\Http\Request;
- class DuplicateRowAction extends RowAction
- {
- protected $title = '复制';
- public function title()
- {
- return $this->title;
- }
- public function handle(Request $request)
- {
- try {
- $id = $this->getKey();
- $repository = app(ItemRepository::class);
- $item = $repository->duplicate($id);
-
- return $this->response()
- ->success("复制成功 [ID: {$item->id}]")
- ->refresh();
- } catch (\Exception $e) {
- return $this->response()
- ->error('复制失败: '.$e->getMessage());
- }
- }
- public function confirm()
- {
- return ['确定要复制此物品吗?', '复制操作将创建一个新的物品记录'];
- }
- }
|