Wait for excel file to be generated before sending mail #3035
-
Hey, really love this package! I have a little question that i could not find in the docs. This is what i have // Get all contrators
$contrators = Contractor::all();
foreach ($contrators as $contrator) {
$data = $this->countRegistrationsDaily($contrator);
$filename = 'public/ContractorStatusDaily-'. now()->format('d-m-Y-H-i-s') .'.xlsx';
Excel::store(new ContractorStatusSheetsExport($data), $filename);
// Send email with excel.
Mail::to($contrator->email)->send(new ContractorStatusExportMail($filename));
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
In your flow, it would only send a mail for the export that succeeded. You could always wrap each contractor loop in a queue job if you want the process to not run out of time: https://laravel.com/docs/8.x/queues#introduction |
Beta Was this translation helpful? Give feedback.
In your flow, it would only send a mail for the export that succeeded.
You could always wrap each contractor loop in a queue job if you want the process to not run out of time: https://laravel.com/docs/8.x/queues#introduction