Compare commits
2
Commits
539239b507
...
16903b21e3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16903b21e3 | ||
|
|
1d4a44b8ac |
@@ -263,12 +263,28 @@ class PetaniController extends Controller
|
|||||||
return redirect()->route('petani.edit', $petani->id)->with('success', 'Data petani berhasil diupdate.');
|
return redirect()->route('petani.edit', $petani->id)->with('success', 'Data petani berhasil diupdate.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*/
|
|
||||||
public function destroy(string $id)
|
public function destroy(string $id)
|
||||||
{
|
{
|
||||||
//
|
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||||
|
return response()->json(['message' => 'Anda tidak memiliki akses.'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$petani = Petani::findOrFail($id);
|
||||||
|
|
||||||
|
$petani->delete();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => 'Data petani berhasil dihapus.'
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Gagal menghapus data: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showImage(string $id, string $field)
|
public function showImage(string $id, string $field)
|
||||||
|
|||||||
Reference in New Issue
Block a user