update view laporan di so
This commit is contained in:
@@ -319,13 +319,15 @@ class SurveyorController extends Controller
|
||||
$newPhotos = $this->processPhotoCategory(
|
||||
$request,
|
||||
$fields,
|
||||
$existingData[$category] ?? []
|
||||
$existingData[$category] ?? [],
|
||||
$category // Pass category to the function
|
||||
);
|
||||
|
||||
$formatFotojson[$category] = $newPhotos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Process single files
|
||||
$singleFiles = ['foto_basement', 'foto_gerbang', 'pendamping'];
|
||||
foreach ($singleFiles as $file) {
|
||||
@@ -351,13 +353,19 @@ class SurveyorController extends Controller
|
||||
/**
|
||||
* Process a photo category and its subcategories
|
||||
*/
|
||||
private function processPhotoCategory(Request $request, array $fields, array $existingPhotos = [])
|
||||
private function processPhotoCategory(Request $request, array $fields, array $existingPhotos = [], $category = null)
|
||||
{
|
||||
$result = $existingPhotos; // Start with existing photos
|
||||
$photoField = $fields[0];
|
||||
$nameField = $fields[1];
|
||||
$descriptionField = $fields[2] ?? null;
|
||||
|
||||
if ($category === 'object_jaminan') {
|
||||
// If it's 'object_jaminan', do not overwrite existing photos, just add new ones
|
||||
$existingPhotos = $existingPhotos ?: [];
|
||||
$result = $existingPhotos;
|
||||
}
|
||||
|
||||
if ($request->hasFile($photoField)) {
|
||||
$newFiles = $request->file($photoField, []);
|
||||
$newNames = $request->input($nameField, []);
|
||||
@@ -367,7 +375,7 @@ class SurveyorController extends Controller
|
||||
foreach ($newFiles as $key => $file) {
|
||||
// Create new photo entry
|
||||
$newPhotoEntry = [
|
||||
$nameField => $newNames[$key] ?? '', // Use new name if provided
|
||||
$nameField => $newNames[$key] ?? '',
|
||||
$photoField => $this->uploadFile($file, $photoField . '.' . $key)
|
||||
];
|
||||
|
||||
@@ -384,6 +392,7 @@ class SurveyorController extends Controller
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function replaceFotoLantaiUnit(Request $request)
|
||||
{
|
||||
// Pastikan foto lantai unit ada dalam request
|
||||
|
||||
Reference in New Issue
Block a user