diff --git a/app/Http/Controllers/DokumenJaminanController.php b/app/Http/Controllers/DokumenJaminanController.php index 5d838d0..60ff7a8 100644 --- a/app/Http/Controllers/DokumenJaminanController.php +++ b/app/Http/Controllers/DokumenJaminanController.php @@ -378,12 +378,16 @@ if ($zip->open($zipFilePath, ZipArchive::CREATE) === true) { foreach ($documents as $document) { - $filePath = storage_path('app/public/' . $document->dokumen_jaminan); - if (file_exists($filePath)) { - $zip->addFile($filePath, basename($filePath)); - } else { - // Log or display an error message for missing files - return redirect()->back()->with('error', 'File not found: ' . $filePath); + $files = is_array(json_decode($document->dokumen_jaminan)) ? json_decode($document->dokumen_jaminan) : [$document->dokumen_jaminan]; + + foreach ($files as $file) { + $filePath = storage_path('app/public/' . $file); + if (file_exists($filePath)) { + $zip->addFile($filePath, basename($filePath)); + } else { + // Log or display an error message for missing files + return redirect()->back()->with('error', 'File not found: ' . $filePath); + } } } $zip->close();