title: Laravel 5 filter on pivot
body: <p>I have two tables Candidates &amp; Qualifications with a joining pivot table called Results.</p>
  
  <p>What I want to do is select all candidates for this centre and filter them by a value in the pivot table.</p>
  
  <p>So select all candidates from centre 1 where the pivot “status” = “REGISTERED”</p>
  
  <p>I have tried numerous approaches and am currently with the one below but nothing is working. </p>
  
  <pre><code>$candidates = Candidate::where('batch_centre_id','=', $id)-&gt;with(array('qualification' =&gt; function($q)
  {
    $q-&gt;wherePivot('status','=', 'REGISTERED');
  }))-&gt;get();
  </code></pre>
  
  <p>Any advice would be much appreciated</p>