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