diff --git a/app/Http/Controllers/DokumenJaminanController.php b/app/Http/Controllers/DokumenJaminanController.php index 207413c..1d62ef3 100644 --- a/app/Http/Controllers/DokumenJaminanController.php +++ b/app/Http/Controllers/DokumenJaminanController.php @@ -392,17 +392,19 @@ if ($zip->open($zipFilePath, ZipArchive::CREATE) === true) { foreach ($documents as $document) { - $files = is_array(json_decode($document->dokumen_jaminan)) ? json_decode( - $document->dokumen_jaminan, - ) : [$document->dokumen_jaminan]; + if($document->dokumen_jaminan) { + $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); + 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); + } } } }