update(['excel_nutzwerte' => '', 'excel_nutzwerte_ok' => '0']); } $projekt = Projekt::where('id', $projekts_id)->first()->toArray(); $filepath = Storage::disk('public')->path("/download/$projekts_id/excel/"); if ($projekt['excel_nutzwerte_ok'] == 0) { $filename = preg_replace("'[^0-9a-zA-Z]'", '', $projekt['intname']).'.xlsx'; if (! File::isDirectory($filepath)) { File::makeDirectory($filepath, 0777, true, true); } $file = $filepath.$filename; GenerateExcel::generate($file, $projekts_id); Projekt::where('id', $projekts_id)->update(['excel_nutzwerte' => $filename, 'excel_nutzwerte_ok' => '1']); } else { $filename = $projekt['excel_nutzwerte']; $file = $filepath.$filename; } $headers = [ 'Content-Type: application/vnd.ms-excel', 'Content-Disposition: attachment;filename="'.$filename.'"', 'Cache-Control: max-age=0', 'Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT', 'Cache-Control: cache, must-revalidate', 'Pragma: public', ]; return Response::download($file, $projekt['name'], $headers); } }