title: Laravel Advanced Wheres how to implement wheres from different table
body: <p>So I have two table and this is the column that they have</p>
  <p>TableA = id, slug, user_id, friend_id, parent_id</p>
  <p>TableB = id, user_id, friend_id</p>
  <p>This is my example coding</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$tableA = TableA::where('slug', '3')-&gt;first();
  
  $tableB = TableB::where( function ($query) use ($tableA) {
      $query-&gt;where('user_id', $tableA-&gt;user_id);
      $query-&gt;where('friend_id', $tableA-&gt;friend_id);
      $query-&gt;where('tableA.parent_id','=','2');
  })-&gt;exists();</code></pre>
  </div>
  </div>
  </p>
  <p>It seems like only this two where conditions are working</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$query - &gt; where('user_id', $tableA - &gt; user_id);
  $query - &gt; where('friend_id', $tableA - &gt; friend_id);</code></pre>
  </div>
  </div>
  </p>
  <p>The last where conditions didn't work. Anyone know what wrong in my coding</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$query - &gt; where('tableA.parent_id', '=', '2');</code></pre>
  </div>
  </div>
  </p>