Compare commits
4
Commits
16903b21e3
...
607533a327
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
607533a327 | ||
|
|
6b25bff2c4 | ||
|
|
71b4d42ea2 | ||
|
|
c42a2571f5 |
@@ -272,7 +272,17 @@ class PetaniController extends Controller
|
|||||||
try {
|
try {
|
||||||
$petani = Petani::findOrFail($id);
|
$petani = Petani::findOrFail($id);
|
||||||
|
|
||||||
$petani->delete();
|
if (auth()->user()->role->value === 'fasilitator' && $petani->created_by !== auth()->id()) {
|
||||||
|
return response()->json(['message' => 'Anda tidak memiliki akses.'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::transaction(function () use ($petani) {
|
||||||
|
$petani->update([
|
||||||
|
'deleted_by' => auth()->id(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$petani->delete();
|
||||||
|
});
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
|
|||||||
Reference in New Issue
Block a user