Fialsafe if no invoices exist
This commit is contained in:
parent
f8e099e133
commit
16edf98dae
|
@ -83,7 +83,7 @@ class SettingsController extends Controller
|
||||||
public function downloadAllInvoices(){
|
public function downloadAllInvoices(){
|
||||||
$zip = new ZipArchive;
|
$zip = new ZipArchive;
|
||||||
$zip_safe_path = storage_path('invoices.zip');
|
$zip_safe_path = storage_path('invoices.zip');
|
||||||
$res = $zip->open($zip_safe_path, ZipArchive::CREATE);
|
$res = $zip->open($zip_safe_path, ZipArchive::CREATE|ZipArchive::OVERWRITE);
|
||||||
$result = $this::rglob(storage_path('app/invoice/*'));
|
$result = $this::rglob(storage_path('app/invoice/*'));
|
||||||
if ($res === TRUE) {
|
if ($res === TRUE) {
|
||||||
foreach($result as $file){
|
foreach($result as $file){
|
||||||
|
@ -93,7 +93,11 @@ class SettingsController extends Controller
|
||||||
}
|
}
|
||||||
$zip->close();
|
$zip->close();
|
||||||
}
|
}
|
||||||
|
if (file_exists($zip_safe_path) && is_file($zip_safe_path)) {
|
||||||
return response()->download($zip_safe_path);
|
return response()->download($zip_safe_path);
|
||||||
|
}else{
|
||||||
|
$this->index()->with('failure', 'No Invoices in Storage!');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue