Got to love simple controller actions!
I love short controller actions that get to the job done. Clean and simple.
public function export(Request $request)
{
// Store on a different disk (e.g. s3)
$fileName = now()->toDateString() . '-registrations.csv';
$disk = 's3';
(new RegistrationsExport(now()->year))
->queue(
$fileName,
$disk,
\Maatwebsite\Excel\Excel::CSV,
)
->chain([
new NotifyUserOfCompletedExport(request()->user(), $fileName, $disk),
])
;
return back()
->with('flash.bannerStyle', 'success')
->with(
'flash.banner',
'Your export is being processed. We will notify you once it is ready.'
)
;
}