original_name; $path = $file->getPath(); break; case 'travel_user': $file = \App\Models\CustomerFewoFile::findOrFail($id); $filename = $file->original_name; $path = $file->getPath(); break; case 'booking': $file = \App\Models\BookingFile::findOrFail($id); $filename = $file->original_name; $path = $file->getPath(); break; case 'general': $file = \App\Models\GeneralFile::findOrFail($id); $filename = $file->original_name; $path = $file->getPath(); break; case 'booking_fewo': $file = \App\Models\TravelUserBookingFile::findOrFail($id); $filename = $file->original_name; $path = $file->getPath(); break; case 'lead': $file = \App\Models\LeadFile::findOrFail($id); $filename = $file->original_name; $path = $file->getPath(); break; case 'cms_file': $file = \App\Models\CMSContent::findOrFail($id); $filename = $file->name; $path = $file->getPath(); break; case 'booking_document': $file = \App\Models\BookingDocument::findOrFail($id); $filename = $file->name; $path = $file->getPath(); break; } if (file_exists($path)) { switch ($do) { case 'file': return Response::file($path); break; case 'download': return Response::download($path, $filename); break; case 'url': return $path.$filename; break; } } } public function showExpert($type = null, $class = null, $year = null, $file = null, $do = null) { /*if ($type == 'xls') { $path = storage_path("app/export/"); $filename = $file . '.xls'; }*/ $path = ""; $filename = ""; $headers = []; if ($class === 'invoices' || $class === 'infos'){ $headers = [ 'Content-Type: application/pdf', 'Pragma: no-cache', 'Cache-Control: no-store,no-cache, must-revalidate, post-check=0, pre-check=0' ]; $dir = $year."/"; $filename = $file; if ($type === 'fewo') { if(Storage::disk('fewo_invoices')->exists( $dir.$filename )){ $path = Storage::disk('fewo_invoices')->path($dir.$filename); } } if ($type === 'fewo') { if(Storage::disk('fewo_infos')->exists( $dir.$filename )){ $path = Storage::disk('fewo_infos')->path($dir.$filename); } } } if (file_exists($path)) { if($do === "download"){ return Response::download($path, $filename, $headers); } if($do === "file"){ return Response::file($path, $headers); } } } }