From e02a34a527576404e1c13364fd1328149a0c26ba Mon Sep 17 00:00:00 2001 From: SyaharaniSalsabilla Date: Wed, 22 Jul 2026 11:58:51 +0700 Subject: [PATCH] solve lahan & tanaman --- .../Controllers/Web/Produktivitas/PetaniController.php | 4 ++-- .../Web/Produktivitas/PetaniLahanController.php | 10 +++++----- .../views/produktivitas/petani/lahan/add.blade.php | 4 ++-- .../views/produktivitas/petani/lahan/edit.blade.php | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Web/Produktivitas/PetaniController.php b/app/Http/Controllers/Web/Produktivitas/PetaniController.php index 336c77a..30c5cd8 100644 --- a/app/Http/Controllers/Web/Produktivitas/PetaniController.php +++ b/app/Http/Controllers/Web/Produktivitas/PetaniController.php @@ -178,7 +178,7 @@ class PetaniController extends Controller 'created_by' => auth()->id(), 'updated_by' => auth()->id()]); - return redirect()->route('petani.index')->with('success', 'Data petani berhasil ditambahkan.'); + return redirect()->route('petani.edit', $petani->id)->with('success', 'Data petani berhasil ditambahkan.'); } public function show(string $id) @@ -253,7 +253,7 @@ class PetaniController extends Controller $petani->update([...$validatedData, 'updated_by' => auth()->id()]); - return redirect()->route('petani.index')->with('success', 'Data petani berhasil diupdate.'); + return redirect()->route('petani.edit', $petani->id)->with('success', 'Data petani berhasil diupdate.'); } /** diff --git a/app/Http/Controllers/Web/Produktivitas/PetaniLahanController.php b/app/Http/Controllers/Web/Produktivitas/PetaniLahanController.php index 47f08ee..6598357 100644 --- a/app/Http/Controllers/Web/Produktivitas/PetaniLahanController.php +++ b/app/Http/Controllers/Web/Produktivitas/PetaniLahanController.php @@ -224,15 +224,15 @@ class PetaniLahanController extends Controller if ($request->ajax()) { return response()->json([ 'success' => true, - 'redirect' => route('petani.lahan-tanaman.index', $petaniId), + 'redirect' => route('petani.lahan-tanaman.edit', [$petaniId, $lahan->id]), 'message' => 'Lahan berhasil ditambahkan.' ]); } - return redirect()->route('petani.lahan-tanaman.index', $petaniId)->with('success', 'Lahan berhasil ditambahkan.'); + return redirect()->route('petani.lahan-tanaman.edit', [$petaniId, $lahan->id])->with('success', 'Lahan berhasil ditambahkan.'); } - return redirect()->route('petani.lahan-tanaman.index', $petaniId)->with('success', 'Lahan berhasil ditambahkan.'); + return redirect()->route('petani.lahan-tanaman.edit', [$petaniId, $lahan->id])->with('success', 'Lahan berhasil ditambahkan.'); } public function show(string $petaniId, string $id) @@ -371,12 +371,12 @@ class PetaniLahanController extends Controller if ($request->ajax()) { return response()->json([ 'success' => true, - 'redirect' => route('petani.lahan-tanaman.index', $petaniId), + 'redirect' => route('petani.lahan-tanaman.edit', [$petaniId, $lahan->id]), 'message' => 'Lahan berhasil diupdate.' ]); } - return redirect()->route('petani.lahan-tanaman.index', $petaniId)->with('success', 'Lahan berhasil diperbarui.'); + return redirect()->route('petani.lahan-tanaman.edit', [$petaniId, $lahan->id])->with('success', 'Lahan berhasil diperbarui.'); } public function destroy(string $id) diff --git a/resources/views/produktivitas/petani/lahan/add.blade.php b/resources/views/produktivitas/petani/lahan/add.blade.php index 2f0e8a5..8f3fc2e 100644 --- a/resources/views/produktivitas/petani/lahan/add.blade.php +++ b/resources/views/produktivitas/petani/lahan/add.blade.php @@ -833,7 +833,7 @@ showConfirmButton: false, timer: 1500 }).then(() => { - window.location.href = "{{ route('petani.index') }}"; + window.location.href = res.redirect || window.location.href; }); }, error: function(xhr) { @@ -870,4 +870,4 @@ }); }); -@endpush \ No newline at end of file +@endpush diff --git a/resources/views/produktivitas/petani/lahan/edit.blade.php b/resources/views/produktivitas/petani/lahan/edit.blade.php index 391dd8e..c8c42d4 100644 --- a/resources/views/produktivitas/petani/lahan/edit.blade.php +++ b/resources/views/produktivitas/petani/lahan/edit.blade.php @@ -900,7 +900,7 @@ showConfirmButton: false, timer: 1500 }).then(() => { - window.location.href = "{{ route('petani.index') }}"; + window.location.href = res.redirect || window.location.href; }); }, error: function(xhr) { @@ -941,4 +941,4 @@ initKomoditas(); }); -@endpush \ No newline at end of file +@endpush