update print out laporan
This commit is contained in:
@@ -306,6 +306,10 @@ class SurveyorController extends Controller
|
||||
|
||||
$formatFotojson = $existingData;
|
||||
|
||||
if ($request->has('foto_lantai_unit')) {
|
||||
$formatFotojson['foto_lantai_unit'] = $this->processFotoLantaiUnit($request);
|
||||
}
|
||||
|
||||
foreach ($photoCategories as $category => $fields) {
|
||||
$photoField = $fields[0];
|
||||
$nameField = $fields[1];
|
||||
@@ -380,6 +384,44 @@ class SurveyorController extends Controller
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function processFotoLantaiUnit(Request $request)
|
||||
{
|
||||
$processedFotoLantaiUnit = [];
|
||||
|
||||
// Ambil semua file foto lantai unit
|
||||
$fotoLantaiUnit = $request->file('foto_lantai_unit', []);
|
||||
|
||||
foreach ($fotoLantaiUnit as $lantaiKey => $files) {
|
||||
$processedFiles = [];
|
||||
|
||||
foreach ($files as $index => $file) {
|
||||
// Pastikan file valid
|
||||
if ($file && $file->isValid()) {
|
||||
// Generate unique filename
|
||||
$filename = $this->generateUniqueFileName($file, "lantai_unit_{$lantaiKey}_{$index}");
|
||||
|
||||
$processedFiles[] = [
|
||||
'path' => $this->uploadFile($file, $filename . '.' . $index),
|
||||
'name' => "Foto Lantai {$lantaiKey} - " . ($index + 1),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Simpan file yang diproses dengan kunci lantai
|
||||
if (!empty($processedFiles)) {
|
||||
$processedFotoLantaiUnit[$lantaiKey] = $processedFiles;
|
||||
}
|
||||
}
|
||||
|
||||
return $processedFotoLantaiUnit;
|
||||
}
|
||||
|
||||
// Fungsi helper untuk generate nama file unik
|
||||
private function generateUniqueFileName($file, $prefix = '')
|
||||
{
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
return $prefix . '_' . uniqid() . '.' . $extension;
|
||||
}
|
||||
|
||||
private function categoryHasNewFiles(Request $request, array $fields): bool
|
||||
{
|
||||
@@ -425,8 +467,7 @@ class SurveyorController extends Controller
|
||||
'foto_rute.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'name_rute.*' => 'required|string|max:255',
|
||||
'lantai.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'name_lantai_unit.*' => 'nullable|string|max:255',
|
||||
'foto_lantai_unit.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
|
||||
'name_rute_lainnya.*' => 'nullable|string',
|
||||
'foto_rute_lainnya.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'foto_lantai_lainnya.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
@@ -435,6 +476,11 @@ class SurveyorController extends Controller
|
||||
'name_basement.*' => 'nullable|string|max:255',
|
||||
'foto_gerbang' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'name_gerbang' => 'nullable|string|max:255',
|
||||
|
||||
|
||||
'name_lantai_unit' => 'array',
|
||||
'foto_lantai_unit' => 'array',
|
||||
'foto_lantai_unit.*' => 'array',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user