title: Laravel belongsToMany exclude pivot table
body: <p>I have two models, <code>User</code> and <code>Badge</code>. A user can have multiple badges, and a badge can belong to multiple users. (using a pivot table)</p>
  
  <p>Currently I am getting the data I need, but additionally I am getting the <code>pivot</code> table along. How do I exclude this?</p>
  
  <p><img src="https://i.stack.imgur.com/HnIbF.png" alt="enter image description here"></p>
  
  <p>Here's the <code>User</code> model:</p>
  
  <pre><code>class User extends Eloquent {
  
      public function badges() {
          return $this-&gt;belongsToMany('Badge', 'users_badges');
      }
  
  }
  </code></pre>
  
  <p>And the <code>Badge</code> model:</p>
  
  <pre><code>class Badge extends Eloquent {
  
      public function users() {
          return $this-&gt;belongsToMany('User', 'users_badges');
      }
  }
  </code></pre>