title: Eloquent belongsToMany withPivot mapping
body: <p>I've inherited 4 MySQL tables:</p>
  
  <p><strong>listings</strong><br>
  -id<br>
  -description<br>
  ...</p>
  
  <p><strong>locations</strong><br>
  -id<br>
  -listing_id</p>
  
  <p><strong>guides</strong><br>
  -id<br>
  -name<br>
  ....</p>
  
  <p><strong>guide_location</strong><br>
  -id<br>
  -guide_id<br>
  -location_id</p>
  
  <p>Listing=>(many) Locations<br>
  Guide=>(many) Locations=>(1) Listing</p>
  
  <p>Listing, Location and Guide each is its own model in a Laravel Dingo application. Here's the setup:</p>
  
  <pre><code>//Listing model
  public function locations()
  {
      return $this-&gt;hasMany('Location');
  }
  </code></pre>
  
  <p>Then </p>
  
  <pre><code>//Location model
  public function guides()
  {
      return $this-&gt;belongsToMany('Guide');
  }
  public function listing()
  {
      return $this-&gt;belongsTo('Listing');
  }
  </code></pre>
  
  <p>And</p>
  
  <pre><code>//Guide model
  public function locations()
  {
      return $this-&gt;belongsToMany('Location');
  }
  </code></pre>
  
  <p>I've added a column to <strong>guide_location</strong> and I want to return it when I select a Guide from the database.</p>
  
  <p>So now:</p>
  
  <p><strong>guide_location</strong><br>
  -id<br>
  -guide_id<br>
  -location_id<br>
  <em>-position</em></p>
  
  <p>I tried adding <code>-&gt;withPivot('position')</code> to both <code>belongsToMany()</code> statements in the Guide and Location models but it's not working, I'm not seeing the new column.</p>
  
  <p>Any ideas what I'm doing wrong?</p>