From bf38962a12b10f9f21aa3caa9b16a99b52032d7a Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 5 Oct 2021 13:01:01 +0800 Subject: [PATCH] download all delivery orders --- routes/web.php | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/routes/web.php b/routes/web.php index f9fbb3c1..4f29e811 100644 --- a/routes/web.php +++ b/routes/web.php @@ -69,30 +69,30 @@ Route::get('/transfer/merge/{marking}', function ($marking) { Route::get('/test', function(){ - Auth::login(User::findOrFail(1)); - try { - $zip_file = 'cief_jun_to_september_delivery_orders.zip'; // Name of our archive to download - $zip = new ZipArchive(); - if ($zip->open(storage_path().'/'.$zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) { - - //whereMonth('created_at', 5)->whereYear('created_at', 2021)-> - $bookings = \App\Models\Booking::where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED)->get(); - - foreach ($bookings as $booking) { - $file = $booking->documents()->where('document_type', \App\Classes\ValueObjects\Constants\DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first(); - if (! $zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), Carbon::now()->format('d_m_Y').'_'.$booking->marking.'.pdf')) { - echo 'Could not add file to ZIP: ' . $file; - } - } - - // Close ZipArchive - $zip->close(); - } else { - echo 'Could not open ZIP file.'; - } - } catch (Exception $exception) { - dd($exception); - } +// Auth::login(User::findOrFail(1)); +// try { +// $zip_file = 'cief_jun_to_september_delivery_orders.zip'; // Name of our archive to download +// $zip = new ZipArchive(); +// if ($zip->open(storage_path().'/'.$zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) { +// +// //whereMonth('created_at', 5)->whereYear('created_at', 2021)-> +// $bookings = \App\Models\Booking::where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED)->get(); +// +// foreach ($bookings as $booking) { +// $file = $booking->documents()->where('document_type', \App\Classes\ValueObjects\Constants\DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first(); +// if (! $zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), Carbon::now()->format('d_m_Y').'_'.$booking->marking.'.pdf')) { +// echo 'Could not add file to ZIP: ' . $file; +// } +// } +// +// // Close ZipArchive +// $zip->close(); +// } else { +// echo 'Could not open ZIP file.'; +// } +// } catch (Exception $exception) { +// dd($exception); +// } });