update form foto

This commit is contained in:
majid76
2024-11-13 07:34:39 +07:00
parent edf293b203
commit 8e9e5e4843
2 changed files with 67 additions and 13 deletions

View File

@@ -360,6 +360,14 @@ class SurveyorController extends Controller
'lantai.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'name_lantai_unit.*' => 'nullable|string|max:255',
'foto_lantai_unit.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'name_rute_lainnya.*' => 'nullable|string',
'foto_rute_lainnya.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'foto_lantai_lainnya.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'name_lantai_lainnya.*' => 'nullable|string|max:255',
'foto_basement.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'name_basement.*' => 'nullable|string|max:255',
'foto_gerbang' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'name_gerbang' => 'nullable|string|max:255',
]);
// DB::beginTransaction();
@@ -369,6 +377,9 @@ class SurveyorController extends Controller
$rute_menuju_lokasi = [];
$object_jaminan = [];
$lingkungan = [];
$foto_lantai_unit = [];
$foto_lantai_lainnya = [];
$foto_rute_lainnya = [];
foreach ($request->file('foto_rute', []) as $key => $value) {
@@ -398,15 +409,61 @@ class SurveyorController extends Controller
];
}
foreach ($request->file('foto_lantai_unit', []) as $key => $value) {
$foto_lantai_unit_Path = $this->uploadFile($request->file('foto_lantai_unit.' . $key), 'foto_lantai_unit.' . $key);
$foto_lantai_unit[] = [
'name_lantai_unit' => $request->input('name_lantai_unit.' . $key),
'foto_lantai_unit' => $foto_lantai_unit_Path,
];
}
foreach ($request->file('foto_rute_lainnya', []) as $key => $value) {
$foto_rute_lainnya_path = $this->uploadFile($request->file('foto_rute_lainnya.' . $key), 'foto_rute_lainnya.' . $key);
$foto_rute_lainnya[] = [
'name_rute_lainnya' => $request->input('name_rute_lainnya.' . $key),
'foto_rute_lainnya' => $foto_rute_lainnya_path,
];
}
foreach ($request->file('foto_lantai_lainnya', []) as $key => $value) {
$foto_lantai_lainnya_path = $this->uploadFile($request->file('foto_lantai_lainnya.' . $key), 'foto_lantai_lainnya.' . $key);
$foto_lantai_lainnya[] = [
'name_lantai_lainnya' => $request->input('name_lantai_lainnya.' . $key),
'foto_lantai_lainnya' => $foto_lantai_lainnya_path,
];
}
$basement = $this->uploadFile($request->file('foto_basement'), 'foto_basement');
$gerbang = $this->uploadFile($request->file('foto_gerbang'), 'foto_gerbang');
$formatFotojson = [
'rute_menuju_lokasi' => $rute_menuju_lokasi,
'object_jaminan' => $object_jaminan,
'lingkungan' => $lingkungan
,'foto_lantai_unit' => $foto_lantai_unit,
'foto_lantai_lainnya' => $foto_lantai_lainnya,
'foto_rute_lainnya' => $foto_rute_lainnya,
'basement' => $basement,
'gerbang' => $gerbang
];
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->first();
if($request->input('permohonan_id') == $inspeksi->permohonan_id){
$inspeksi->update([
'foto_form' => json_encode($formatFotojson)
]);
}else {
Inspeksi::create([
'permohonan_id' => $request->input('permohonan_id'),
'foto_form' => json_encode($formatFotojson)
]);
}
// DB::commit();

View File

@@ -175,10 +175,7 @@
</div>
@endforeach
@else
{{-- <img id="foto_rute-preview"
src="{{ asset('storage/' . (isset($forminspeksi['foto_rute[]']) ? $forminspeksi['foto_rute[]'] : '')) }}"
alt="Foto Argis Region" class="mt-2 max-w-full h-auto"
style="{{ isset($forminspeksi['foto_rute']) ? '' : 'display: none;' }}"> --}}
<div id="inputContainerRute" style="margin-top: 10px">
<div class="flex w-full items-center justify-center gap-4 mb-4">
@@ -188,8 +185,8 @@
<div class="input-group w-full flex gap-2">
<input class="name_rute" type="hidden" name="name_rute[]" value="rute">
<img id="foto_rute-preview" src="" alt="Foto Argis Region"
class="mt-2 max-w-full h-auto" style="display: none;">
{{-- <img id="foto_rute-preview" src="" alt="Foto Argis Region"
class="mt-2 max-w-full h-auto" style="display: none;"> --}}
<input id="inputRute" type="file" name="foto_rute[]"
class="file-input file-input-bordered w-full" accept="image/*" capture="camera"
onchange="previewImage(this, 'foto_rute-preview')">
@@ -220,9 +217,9 @@
</label>
<div class="input-group w-full flex gap-2">
<input class="name_gerbang" type="hidden" name="foto_gerbang" value="rute">
<img id="foto_gerbang-preview" src="" alt="Foto Gerbong"
class="mt-2 max-w-full h-auto" style="display: none;">
<input class="name_gerbang" type="hidden" name="name_gerbang" value="rute">
{{-- <img id="foto_gerbang-preview" src="" alt="Foto Gerbong"
class="mt-2 max-w-full h-auto" style="display: none;"> --}}
<input id="inputRute" type="file" name="foto_gerbang"
class="file-input file-input-bordered w-full" accept="image/*" capture="camera"
onchange="previewImage(this, 'foto_gerbang-preview')">
@@ -394,8 +391,8 @@
<span class="form-label">Basement</span>
</label>
<div class="input-group w-full flex gap-2">
<input type="hidden" name="name_lantai_unit[]" value="lantai">
<input id="inputLantai" type="file" name="foto_lantai_unit[]"
<input type="hidden" name="name_basement" value="basement">
<input id="inputLantai" type="file" name="foto_basement"
class="file-input file-input-bordered w-full" accept="image/*" capture="camera">
<button type="button" id="btnCamera" class="btn btn-light"
data-modal-toggle="#cameraModal">
@@ -759,7 +756,7 @@
<div class="flex flex-wrap items-baseline w-full">
<div class="flex flex-col lg:flex-row gap-2 w-full">
<div class="flex flex-wrap items-baseline px-2">
<input class="input" type="text" name="${inputName}[]">
<input class="input" type="text" name="name_${inputName}[]">
</div>
<div class="flex flex-wrap items-baseline w-full">
<div class="input-group w-full flex gap-2">