title: Export PDF from Laravel
body: <p>I'm trying to export a table in PDF, but I have a foreach and I want to export all data from foreach, but is not working for all, just for a row.</p>
  
  <p>Here is the code:   </p>
  
  <pre><code>foreach ($posts as $post) {
      $html = '&lt;div class="table-scrollable"&gt;
                      &lt;table id="posts" class="table table-bordered table-hover"&gt;
                          &lt;thead&gt;
                              &lt;tr&gt;
                                  &lt;th&gt;Id&lt;/th&gt;
                                  &lt;th&gt;Name&lt;/th&gt;
                                  &lt;th&gt;Title&lt;/th&gt;
                              &lt;/tr&gt;
                          &lt;/thead&gt;
                          &lt;tbody id="body"&gt;&lt;tr&gt;
                              &lt;td&gt;'
              . $post-&gt;id . ' 
                              &lt;/td&gt;
                              &lt;td&gt;' .
              $post-&gt;name .
              '&lt;/td&gt;
                              &lt;td&gt;'
              . $post-&gt;title .
              '&lt;/td&gt; 
                  &lt;/tr&gt;
                 &lt;/tbody&gt;
              &lt;/table&gt;
          &lt;/div&gt;';
  }
  return PDF::load($html, 'A4', 'portrait')-&gt;download('my_pdf');
  </code></pre>