title: Laravel Eloquent relationship Many to Many
body: <p>A user can have one whitelabel.<br>
  A whitelabel can have many users.<br>
  I have a pivot table with <code>whitelabel_id</code>, and <code>user_id</code> columns
  I have both relationships set up using <code>-&gt;belongsToMany()</code> (with the inverse).</p>
  
  <p>I am using a pivot table because I don't have a whitelabel_id on the users table (and won't be putting one in) so its defined as a <code>many-to-many</code>, but really it's <code>one-to-many</code>. I just get the <code>first()</code> whitelabel as there'll only be one for each user.</p>
  
  <p>With this in mind. How do I <code>select * users</code> with the currently authenticated user's whitelabel?</p>
  
  <p>I have this, it works, but is this the "Laravel" way? I feel it's slightly over engineered and Laravel would have a shorthand method.</p>
  
  <pre><code>$user-&gt;when(auth()-&gt;user()-&gt;whitelabel-&gt;first(), function ($query) {
      return 
      $query-&gt;whereIn('id', auth()-&gt;user()-&gt;whitelabel-&gt;first()-&gt;users-&gt;pluck('id'));
  })
  </code></pre>
  
  <p>This checks if the auth user has a whitelabel, and then gets all users with the same whitelabel.</p>
  
  <p><strong>Does Laravel have a quick shorthand for this?</strong></p>