diff --git a/app/Http/Controllers/BendingBaseController.php b/app/Http/Controllers/BendingBaseController.php index 457e9ccd..54af8899 100644 --- a/app/Http/Controllers/BendingBaseController.php +++ b/app/Http/Controllers/BendingBaseController.php @@ -203,6 +203,21 @@ public function update(Request $request, int $id) return redirect()->route('bending.base.show', $id)->with('success', '절곡품이 수정되었습니다.'); } + public function duplicate(int $id) + { + $response = $this->api()->post("/api/v1/bending-items/{$id}/duplicate"); + + if (! $response->successful()) { + return back()->withErrors(['api' => $response->json('message', '복사 실패')]); + } + + $newId = $response->json('data.id'); + $newCode = $response->json('data.code'); + + return redirect()->route('bending.base.edit', $newId) + ->with('success', "복사 완료 — 새 코드: {$newCode}"); + } + public function destroy(int $id) { $this->api()->delete("/api/v1/bending-items/{$id}"); diff --git a/resources/views/bending/base/form.blade.php b/resources/views/bending/base/form.blade.php index 2e05ac53..9fc87775 100644 --- a/resources/views/bending/base/form.blade.php +++ b/resources/views/bending/base/form.blade.php @@ -34,6 +34,7 @@ 수정 @endif @if(!$isCreate) +