solve lahan & tanaman

This commit is contained in:
2026-07-22 11:58:51 +07:00
parent 12f8d0bbda
commit e02a34a527
4 changed files with 11 additions and 11 deletions
@@ -178,7 +178,7 @@ class PetaniController extends Controller
'created_by' => auth()->id(), 'created_by' => auth()->id(),
'updated_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) public function show(string $id)
@@ -253,7 +253,7 @@ class PetaniController extends Controller
$petani->update([...$validatedData, $petani->update([...$validatedData,
'updated_by' => auth()->id()]); '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.');
} }
/** /**
@@ -224,15 +224,15 @@ class PetaniLahanController extends Controller
if ($request->ajax()) { if ($request->ajax()) {
return response()->json([ return response()->json([
'success' => true, 'success' => true,
'redirect' => route('petani.lahan-tanaman.index', $petaniId), 'redirect' => route('petani.lahan-tanaman.edit', [$petaniId, $lahan->id]),
'message' => 'Lahan berhasil ditambahkan.' '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) public function show(string $petaniId, string $id)
@@ -371,12 +371,12 @@ class PetaniLahanController extends Controller
if ($request->ajax()) { if ($request->ajax()) {
return response()->json([ return response()->json([
'success' => true, 'success' => true,
'redirect' => route('petani.lahan-tanaman.index', $petaniId), 'redirect' => route('petani.lahan-tanaman.edit', [$petaniId, $lahan->id]),
'message' => 'Lahan berhasil diupdate.' '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) public function destroy(string $id)
@@ -833,7 +833,7 @@
showConfirmButton: false, showConfirmButton: false,
timer: 1500 timer: 1500
}).then(() => { }).then(() => {
window.location.href = "{{ route('petani.index') }}"; window.location.href = res.redirect || window.location.href;
}); });
}, },
error: function(xhr) { error: function(xhr) {
@@ -870,4 +870,4 @@
}); });
}); });
</script> </script>
@endpush @endpush
@@ -900,7 +900,7 @@
showConfirmButton: false, showConfirmButton: false,
timer: 1500 timer: 1500
}).then(() => { }).then(() => {
window.location.href = "{{ route('petani.index') }}"; window.location.href = res.redirect || window.location.href;
}); });
}, },
error: function(xhr) { error: function(xhr) {
@@ -941,4 +941,4 @@
initKomoditas(); initKomoditas();
}); });
</script> </script>
@endpush @endpush