percorso_file) ? trim((string) $documentoStabile->percorso_file) : ''; if ($path === '') { abort(404); } $selectedDisk = null; if (Storage::disk('public')->exists($path)) { $selectedDisk = 'public'; } elseif (Storage::disk('local')->exists($path)) { $selectedDisk = 'local'; } if (! $selectedDisk) { abort(404); } $filename = is_string($documentoStabile->nome_originale) && trim((string) $documentoStabile->nome_originale) !== '' ? trim((string) $documentoStabile->nome_originale) : ((is_string($documentoStabile->nome_file) && trim((string) $documentoStabile->nome_file) !== '') ? trim((string) $documentoStabile->nome_file) : ('documento-stabile-' . (int) $documentoStabile->id . '.pdf')); $filename = str_replace(["\r", "\n", '"'], '', $filename); $documentoStabile->incrementaDownload(); if ($request->boolean('inline')) { return response()->file(Storage::disk($selectedDisk)->path($path), [ 'Content-Disposition' => 'inline; filename="' . $filename . '"', ]); } return Storage::disk($selectedDisk)->download($path, $filename); } }