title: Laravel With and wherePivot
body: <p>I'm trying to extract all companies and contacts with pivot.main_contact = 1.</p>
  
  <p>Tables:</p>
  
  <pre><code>Company: id, name
  Company_contacts: id, company_id, contact_id, main_contact
  Contacts: id, name
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>class Company extends Model
  {
          public function mainContact()
      {
          return $this-&gt;belongsToMany('App\Contact', 'company_contacts')
                          -&gt;wherePivot('main_contact', '=', 1);
      }
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>$query = Company::with('mainContact')-&gt;get();   
  </code></pre>
  
  <p>This returns companies + ALL contacts for the companies and NOT ONLY the ones with main_contact = 1. </p>