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
@@ -403,6 +403,7 @@
<div class="row mt-3">
<div class="col-12 text-end">
<a href="{{ route('petani.index') }}" class="btn btn-secondary me-2 wave-effect wave-light">Kembali</a>
<button id="delete-lahan"type="button" class="btn btn-danger data-submit wave-effect wave-light"><i class="ti tabler-trash me-2"></i> Hapus Lahan</button>
<button type="submit" class="btn btn-success data-submit wave-effect wave-light"><i class="ti tabler-device-floppy me-2"></i> Simpan Lahan</button>
</div>
</div>
@@ -1017,7 +1018,7 @@
showConfirmButton: false,
timer: 1500
}).then(() => {
window.location.href = "{{ route('petani.index') }}";
window.location.href = "{{ route('petani.lahan-tanaman.index', ['petani' => $petani->id]) }}";
});
},
error: function(xhr) {
@@ -1054,6 +1055,29 @@
}
});
$('#delete-lahan').click(function(e) {
e.preventDefault();
$.ajax({
url: "{{ route('petani.lahan-tanaman.destroy', ['petani' => $petani->id, 'lahan_tanaman' => $lahanSelected->id]) }}",
type: "POST",
data: {
_method: 'DELETE',
_token: $('input[name="_token"]').val()
},
success: function(res) {
Swal.fire({
icon: 'success',
title: 'Berhasil!',
text: 'Data lahan berhasil dihapus.',
showConfirmButton: false,
timer: 1500
}).then(() => {
window.location.href = "{{ route('petani.lahan-tanaman.index', ['petani' => $petani->id]) }}";
});
}
});
});
initWilayah();
initKomoditas();
});