title: Download file in laravel
body: <p>I am new to Laravel and I trying to capture the filename stored on the database table called "Infrastructure" so that I can create a link for users to downloading that file. The download works but I always get the wrong file stored in the directory.</p>
  
  <p>So in my controller called infrastructureController.php I have these codes.</p>
  
  <pre><code>public function show($id)
      {
          $infrastructure = $this-&gt;infrastructureRepository-&gt;find($id);
          $Attachment = $infrastructure-&gt;inf_file; // captured filename in the database
  
          if (empty($infrastructure)) {
              Flash::error('Infrastructure not found');
  
              return redirect(route('infrastructures.index'));
          }
  
          return view('infrastructures.show')-&gt;with('infrastructure', $infrastructure);
      }
  </code></pre>
  
  <p>In my route or web.php</p>
  
  <p>I have these codes...</p>
  
  <pre><code>Route::get('/download', function(){
      $name = $Attachment;
  
      $file = storage_path()."/app/public/infrastructure/".$Attachment;
  
      $headers  = array(
          'Content-Type: application/pdf',
      );
  
      return Response::download($file, $name, $headers);
  });
  </code></pre>
  
  <p>and finally, in my view file, I have this</p>
  
  <pre><code>&lt;!-- Inf File Field   --&gt;
  &lt;div class="form-group"&gt;
      {!! Form::label('inf_file', 'Attachements:') !!}
      &lt;a href="/download"&gt;Download Now&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Can someone point out I did wrong here...</p>