From 39af10ff95fc8efce9c93cd0d2aa8eeb8e2bebc2 Mon Sep 17 00:00:00 2001 From: 1day2die Date: Tue, 7 Dec 2021 20:27:54 +0100 Subject: [PATCH] formatting --- .../Controllers/Admin/SettingsController.php | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/Admin/SettingsController.php b/app/Http/Controllers/Admin/SettingsController.php index 29adc72a..42ba8e95 100644 --- a/app/Http/Controllers/Admin/SettingsController.php +++ b/app/Http/Controllers/Admin/SettingsController.php @@ -72,33 +72,31 @@ class SettingsController extends Controller return redirect()->route('admin.settings.index')->with('success', 'Invoice settings updated!'); } - public function rglob($pattern, $flags = 0) { - $files = glob($pattern, $flags); - foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { - $files = array_merge($files, $this::rglob($dir.'/'.basename($pattern), $flags)); - } - return $files; - } - - public function downloadAllInvoices(){ + public function downloadAllInvoices() + { $zip = new ZipArchive; $zip_safe_path = storage_path('invoices.zip'); - $res = $zip->open($zip_safe_path, ZipArchive::CREATE|ZipArchive::OVERWRITE); + $res = $zip->open($zip_safe_path, ZipArchive::CREATE | ZipArchive::OVERWRITE); $result = $this::rglob(storage_path('app/invoice/*')); if ($res === TRUE) { - $zip->addFromString("1. Info.txt","This Archive contains all Invoices from all Users!\n If there are no Invoices here, no Invoices have ever been created!"); - foreach($result as $file){ + $zip->addFromString("1. Info.txt", "This Archive contains all Invoices from all Users!\nIf there are no Invoices here, no Invoices have ever been created!"); + foreach ($result as $file) { if (file_exists($file) && is_file($file)) { - $zip->addFile($file,basename($file)); + $zip->addFile($file, basename($file)); } } $zip->close(); } - if (file_exists($zip_safe_path) && is_file($zip_safe_path)) { - return response()->download($zip_safe_path); - }else{ - $this->index()->with('failure', 'No Invoices in Storage!'); + return response()->download($zip_safe_path); + } + + public function rglob($pattern, $flags = 0) + { + $files = glob($pattern, $flags); + foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { + $files = array_merge($files, $this::rglob($dir . '/' . basename($pattern), $flags)); } + return $files; } }