title: How to export PDF file in Laravel
body: <p>I have two views. One is to show filter view (View 1). Another one is to get data from filter view and then export to PDF file (View 2). It means that when "Print" is clicked, PDF file will be exported and View 2 will be view of PDF file with data of View 1.</p>
  
  <p>Now I dont know how to get data from View 1 and show into View 2.</p>
  
  <p>Here is my code:</p>
  
  <p>View1:</p>
  
  <pre><code>&lt;form method="get"&gt;
      &lt;select name="type" onchange="this.form.submit()"&gt;
          &lt;option value=""&gt;All types&lt;/option&gt;
          @foreach ($types as $item)
              &lt;option value="{{ $item-&gt;id }}" @if ($request-&gt;type == $item-&gt;id) selected @endif&gt;{{ $item-&gt;name }}&lt;/option&gt;
          @endforeach
      &lt;/select&gt;
  &lt;/form&gt;
  &lt;br&gt;
  &lt;a href="pdf"&gt;Print&lt;/a&gt;
  &lt;br&gt;&lt;br&gt;
      &lt;table border="1"&gt;
          &lt;tr&gt;
              &lt;th&gt;ID&lt;/th&gt;
              &lt;th&gt;Content&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
          &lt;/tr&gt;
          @foreach ($data as $q)
              &lt;?php $typeName = App\Type::find($q-&gt;type_id);?&gt;
              &lt;tr&gt;
                  &lt;td&gt;{{ $q-&gt;id }}&lt;/td&gt;
                  &lt;td&gt;{{ $q-&gt;content }}&lt;/td&gt;
                  &lt;td&gt;{{ $typeName-&gt;name }}&lt;/td&gt;
              &lt;/tr&gt;
          @endforeach
      &lt;/table&gt;
  </code></pre>
  
  <p>View2:
  This view will be shown at PDF file but I dont know how to get value from View1</p>
  
  <pre><code>&lt;table border="1"&gt;
      &lt;tr&gt;
          &lt;th&gt;ID&lt;/th&gt;
          &lt;th&gt;Content&lt;/th&gt;
          &lt;th&gt;Type&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>FilterController:</p>
  
  <pre><code>public function getFilter(Request $request){
          $types = Type::all();
          $model = Question::where('id', '&gt;', 0)-&gt;with('types');
  
          if (isset($request-&gt;type))
              $model = $model-&gt;where('type_id', $request-&gt;type);
          $data = $model-&gt;paginate(15)-&gt;appends(request()-&gt;query());
  
          return view('View1', compact( 'data', 'request', 'types'));
      }
  </code></pre>
  
  <p>PrintController:</p>
  
  <pre><code>public function getValueFromView2(){
  //I've to write something to get value from View1
  }
  public function getPDF(){
          $pdf = PDF::loadView('View2');
          return $pdf-&gt;download('test.pdf');
  }
  </code></pre>
  
  <p>View1 with filter function is working fine. What I want is to export PDF file with data of View1 after filtering</p>