title: Use Eloquent to filter by pivot table in Laravel 5.3
body: <p>I am using Laravel's (5.3) Eloquent ORM and try to filter using a pivot table. I have three tables: <code>events</code>, <code>supervisors</code> and <code>event_has_supervisors</code>. Now I just want all events assigned to a certain supervisor.</p>
  
  <p>In my Event Model I got this:</p>
  
  <pre><code>public function supervisors() {
      return $this-&gt;belongsToMany(Supervisor::class, 'event_has_supervisors')-&gt;withPivot('hours');
  }
  </code></pre>
  
  <p>In my Controller I now need to query all events, given a few criteria:</p>
  
  <pre><code>$events = Event::with($relations);
  // This works well: get all Events in one or more given cities
  $events = $events-&gt;whereIn('events.place_id', $cities);
  // This does not work
  $events = $events-&gt;whereIn('events.supervisor_id', $supervisors);
  </code></pre>
  
  <p>Obviously, the last where-clause doesn't work, because there is no such attribute on my events table. But how can I query my pivot table in this case? I want any of the supervisors assigned to the event to be any of the supervisors in <code>$supervisors</code>.</p>