foto lahan
This commit is contained in:
@@ -140,9 +140,21 @@ class PetaniLahanController extends Controller
|
||||
$komoditas = Komoditas::where('id', $request->komoditas_id)->first();
|
||||
$lahanCount = Lahan::where('petani_id', $petaniId)
|
||||
->count();
|
||||
|
||||
$lahanUid = strtoupper(Str::random(10));
|
||||
|
||||
if ($request->hasFile('foto')) {
|
||||
$foto = [];
|
||||
foreach ($request->file('foto') as $file) {
|
||||
$path = $file->store('lahan', 'public');
|
||||
$foto[] = [
|
||||
'path' => $path,
|
||||
'file' => $file->getClientOriginalName(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$lahan = Lahan::create([...$validated,
|
||||
'foto' => $foto && count($foto) > 0 ? json_encode($foto) : null,
|
||||
'nama' => 'Lahan ' . $komoditas->nama . ' #' . ($lahanCount + 1),
|
||||
'uid' => 'LHN-' . $petani->uid . '-' . $lahanUid,
|
||||
'petani_id' => $petaniId,
|
||||
|
||||
Reference in New Issue
Block a user