title: How to display PDF Documents on the browser using a View in Laravel 5.8
body: <p>I'm working on a web application using Laravel 5.8, I'm new to Laravel framework. I would like to display PDF documents on the browser when users click on some buttons. I will allow authenticated users to "View" and "Download" the PDF documents.</p>
  
  <p>I have created a Controller and a Route to allow displaying of the documents. I'm however stuck because I have a lot of documents and I don't know how to use a Laravel VIEW to display and download each document individually.</p>
  
  <p>/* PDFController*/</p>
  
  <pre><code>public function view($id)
  {
      $file = storage_path('app/pdfs/') . $id . '.pdf';
  
      if (file_exists($file)) {
  
          $headers = [
              'Content-Type' =&gt; 'application/pdf'
          ];
  
          return response()-&gt;download($file, 'Test File', $headers, 'inline');
      } else {
          abort(404, 'File not found!');
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>/<em>The Route</em>/
  Route::get('/preview-pdf/{id}', 'PDFController@view');</p>