title: Laravel Eloquent Many-to-Many query whereIn
body: <p>In my application I have updated a relationship from <code>one-to-many</code> to <code>many-to-many</code> and I'm trying to figure out a way to persist associated functionality.</p>
  
  <p>Let's say I have two related tables, e.g. dogs and owners. If I have an array of owners and I'm trying to get a list of dogs id's for those owners, how should I do it eloquently?</p>
  
  <p>Similar question was asked here:
  <a href="https://laracasts.com/discuss/channels/laravel/getting-many-to-many-related-data-for-an-array-of-elements" rel="noreferrer">https://laracasts.com/discuss/channels/laravel/getting-many-to-many-related-data-for-an-array-of-elements</a></p>
  
  <p>So, How would I get the <code>Dog</code> models where <code>Owner</code> is in an array ?</p>
  
  <p>Same thing as <code>$associatedDogs = Dog::whereIn('owner_id',$ListOfOwners)-&gt;get();</code> is for a <code>One-To-Many</code> relationship, but for <code>Many-to-Many</code>.</p>