title: Pass Variables to generate PDF using php
body: <p><strong>Web.php</strong> I tried making a blank route to pass the $contract variables to pass the variables through to generate the pdf using dompdf</p>
  
  <pre><code>Route::get('/blank', function () {
      return view('sell.contractpdf','PdfGenerateController@contract')-&gt;name('viewpdf');
  });
  </code></pre>
  
  <p><strong>contractpdf controller</strong></p>
  
  <pre><code>public function pdfview(Request $request)
  {
      $contract = Contract::findOrFail(session('contract_id'));
      $pdf = App::make('dompdf.wrapper');
      $pdf = PDF::loadView('sell.contractpdf', $contract);
      return $pdf-&gt;stream();
  }
  </code></pre>
  
  <p><strong>In the View:</strong></p>
  
  <pre><code>&lt;h1&gt;f&lt;/h1&gt;
  @foreach ($contracts as $contract)
  &lt;h4&gt;{{$contract-&gt;id}}&lt;/h4&gt;
  @endforeach
  </code></pre>
  
  <p><strong>ERROR:
  Undefined variable: contracts</strong> </p>