title: how to run mysql query in Laravel
body: <p>I want to transform my MySql query into a Query in Laravel but I really don't know how to do this. I don't know how to rename in FROM like in SQL</p>
  
  <p>My query is the following one :</p>
  
  <pre><code>SELECT f2.* FROM formation f2 WHERE f2.theme_id IN 
  (SELECT f.theme_id FROM user_formation uf JOIN formation f ON uf.formation_id = f.id WHERE uf.user_id = 2) 
  AND f2.id NOT IN 
  (SELECT formation_id FROM user_formation WHERE user_id = 2);
  </code></pre>
  
  <p>I tried something like this but ...</p>
  
  <pre><code>$q = Formation::query()
                  -&gt;from('formation AS f2')
                  -&gt;whereIn('f2.theme_id', function($r)
                  {
                      $r-&gt;select('f.theme_id')-&gt;from('user_formation AS uf')
                      -&gt;join('formation', function($join)
                      {
                          $join-&gt;on('uf.formation_id', '=', 'f.id')
                          -&gt;where ('uf.user_id', '=', $id)
                      });
                  });
  
              -&gt;whereNotIn('f2.id', function($s){
                  $s-&gt;select('formation.id')
                  -&gt;from('user_formation')
                  -&gt;where('user_id', '=', $id)
              })-&gt;get();
  
  </code></pre>
  
  <p>thanks for help.</p>