petani lahan hapus

This commit is contained in:
2026-07-22 14:38:10 +07:00
parent 50c9adfdc7
commit 2c94316439
2 changed files with 41 additions and 3 deletions
@@ -379,9 +379,23 @@ class PetaniLahanController extends Controller
return redirect()->route('petani.lahan-tanaman.index', $petaniId)->with('success', 'Lahan berhasil diperbarui.');
}
public function destroy(string $id)
public function destroy(string $petaniId, string $id)
{
//
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
abort(403);
}
$lahan = Lahan::findOrFail($id);
$lahan->tanaman()->update([
'deleted_by' => auth()->id()
]);
$lahan->tanaman()->delete();
$lahan->update([
'deleted_by' => auth()->id()
]);
$lahan->delete();
return redirect()->route('petani.lahan-tanaman.index', $petaniId)->with('success', 'Lahan berhasil dihapus.');
}
public function summary(string $petaniId)