This commit is contained in:
Dwi Swandhana
2026-08-20 06:17:59 +07:00
parent e974c2a57c
commit 997a0fe192
@@ -81,20 +81,19 @@ class JsonTransferController extends Controller
return response()->download($file);
}
public function downloadAll(){
$zipFile = base_path('database/seeders/data/all_json.zip');
$zip = new ZipArchive;
File::delete($zipFile);
if ($zip->open($zipFile, ZipArchive::CREATE) === TRUE) {
foreach (File::files(base_path($this->exportPath)) as $file) {
$zip->addFile($file->getRealPath(), basename($file));
}
$zip->close();
public function downloadAll()
{
$targetDir = base_path('database/seeders/data/');
$zipFile = $targetDir . 'all_json.zip';
if (file_exists($zipFile)) {
File::delete($zipFile);
}
return response()->download($zipFile);
$command = "cd {$targetDir} && zip -r all_json.zip .";
shell_exec($command);
if (file_exists($zipFile)) {
return response()->download($zipFile);
}
return back()->with('error', 'Gagal membuat file ZIP.');
}
public function importTable($table) {