petani lahan tanaman edit

This commit is contained in:
2026-07-14 14:50:33 +07:00
parent 2c28bb06db
commit a1dadd1b1b
4 changed files with 74 additions and 23 deletions
@@ -141,7 +141,8 @@ class PetaniLahanController extends Controller
$lahanCount = Lahan::where('petani_id', $petaniId)
->count();
$lahanUid = strtoupper(Str::random(10));
$foto = null;
if ($request->hasFile('foto')) {
$foto = [];
foreach ($request->file('foto') as $file) {
@@ -188,6 +189,14 @@ class PetaniLahanController extends Controller
Tanaman::insert($chunk->toArray());
});
if ($request->ajax()) {
return response()->json([
'success' => true,
'redirect' => route('petani.lahan-tanaman.index', $petaniId),
'message' => 'Lahan berhasil ditambahkan.'
]);
}
return redirect()->route('petani.lahan-tanaman.index', $petaniId)->with('success', 'Lahan berhasil ditambahkan.');
}
}