diff --git a/app/Console/Commands/SeedingPrepare.php b/app/Console/Commands/SeedingPrepare.php new file mode 100644 index 0000000..c004fd4 --- /dev/null +++ b/app/Console/Commands/SeedingPrepare.php @@ -0,0 +1,65 @@ +info('Downloading ZIP file...'); + $zipContent = file_get_contents($zipUrl); + file_put_contents($localZipPath, $zipContent); + + // Check if the ZIP file was successfully downloaded + if (!file_exists($localZipPath)) { + $this->error('Failed to download the ZIP file.'); + return; + } + + // Unzipping the file + $this->info('Unzipping the file...'); + $zip = new \ZipArchive(); + if ($zip->open($localZipPath) === TRUE) { + // Create the extraction directory if it doesn't exist + if (!file_exists($extractPath)) { + mkdir($extractPath, 0777, true); + } + + // Extract the ZIP file to the specified directory + $zip->extractTo($extractPath); + $zip->close(); + $this->info('File unzipped successfully.'); + } else { + $this->error('Failed to unzip the file.'); + } + + // Optionally, delete the zip file after extraction + unlink($localZipPath); + } +}