title: Join query with foreach in Laravel
body: <p>I am trying to learn Laravel, so I apologize if my question is simple.<br/> I have 2 table (table1, table2) like this:<br/>
  table1:<br/></p>
  
  <pre><code>ID       date       time
  1          1          1
  2          4          2
  3          5          3
  </code></pre>
  
  <p>table2: <br/></p>
  
  <pre><code>ID       V        R
  1        123       T
  1        12        F
  1        43        F
  2        32        T
  2        23        T
  3        43        F
  </code></pre>
  
  <p>because I have 3 type of IDs (which could be more or less) I want to divide table2 into 3 tables using table1. like this: <br/>
  table2_1: for ID:1</p>
  
  <pre><code>V       R
  123     T
  12      F
  43      F
  </code></pre>
  
  <p>table2_2: for ID:2</p>
  
  <pre><code>V       R
  23       T
  23       T
  </code></pre>
  
  <p>table2_3: for ID:3</p>
  
  <pre><code>V       R
  43       F
  </code></pre>
  
  <p>I think I need somthing like this: <br/></p>
  
  <pre><code>@foreach ($table1 as $t)
        &lt;table class="table"&gt;
           {!! $t -&gt; ID!!}
          &lt;thead&gt;
          &lt;tr&gt;
  
              &lt;th scope="col"&gt;R&lt;/th&gt;
              &lt;th scope="col"&gt;V&lt;/th&gt;
  
          &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
  
              &lt;!---Query result ----&gt;
  
          &lt;/tbody&gt;
  
   @endforeach
  </code></pre>
  
  <p>which in Query result I need a to select V and R from joining table1 and table2.<br/>
  but I don'n know the exact code. <br/>
  Any Idea how can I do this? Thanks in advance.</p>