title: Alternate of with clause in query builder in laravel
body: <p>I write a query using Eloquent in laravel 5 in which i use <code>with Clause</code> but when i write the query in laravel query Builder in which i cannot find any <code>with Clause</code> Please tell me the alternate of with Clause in query builder.</p>
  
  <p>Here is my query in eloquent:</p>
  
  <pre><code>$invitedOnActivity = $this-&gt;isInvitedOnActivity($activity-&gt;id, $activity-&gt;user_id, $authUser-&gt;id);
  
          if($invitedOnActivity == true &amp;&amp; $activity-&gt;activity_privacy == 'invite_only'){
  
              if($activity-&gt;activity_privacy_visible == 0)
                  {
                      $activity = Activity::where('id', $activity-&gt;id)-&gt;with(['joins' =&gt; function($query) use ($userFriendIds) {
                          $query-&gt;whereIn('user_id', $userFriendIds);
                      }])-&gt;withCount(['joins' =&gt; function ($query) use ($userFriendIds) {
                          $query-&gt;whereIn('user_id', $userFriendIds);
                      }])-&gt;first();
                          // return response()-&gt;json(['q'=&gt;$activity],200);
                  } 
                  else if ($activity-&gt;activity_privacy_visible == 1 &amp;&amp; in_array($activity-&gt;user_id, $userFriendIds))
                  {
                      $activity = Activity::where('id', $activity-&gt;id)-&gt;where('activity_privacy_visible', 1)-&gt;with(['joins' =&gt; function($query) use ($userFriendIds) {
                          $query-&gt;whereIn('user_id', $userFriendIds);
                      }])-&gt;withCount(['joins' =&gt; function ($query) use ($userFriendIds){
                          $query-&gt;whereIn('user_id', $userFriendIds);
                      }])-&gt;first();
                          // return response()-&gt;json(['w'=&gt;$activity],200);      
                  } 
                  else {
                      continue;
                  }
          }  
  </code></pre>
  
  <p>i want this query to change in query builder. Here is the query i will tried but i think its not work.</p>
  
  <pre><code>if($invitedOnActivity == false){
              $activity = DB::table('activities')
                  -&gt;where('id', $activity-&gt;id)
                  -&gt;where('activity_privacy', 'invite_only')
                  -&gt;where('activity_privacy_visible', 0)
                  -&gt;get();
          }
  </code></pre>
  
  <p>In this query i could not find alternate of with clause. Please Help Me. Thanks in Advance.</p>