title: Laravel - hasManyThrough and eager loading, get column from related
body: <p>I'm getting some weird stuff going on when trying to eager load a related model using hasManyThrough.</p>
  
  <p>I have a Community model which has a function called 'roommates' to get all Users that have the community id in a column called 'community', see below code.</p>
  
  <pre><code>    public function roommates()
      {
          return $this-&gt;hasManyThrough('App\User', 'App\Community', 'id', 'community');
      }
  </code></pre>
  
  <p>Then the User model is grabbed from Auth after login and eager loads the related models, and only displaying the columns I want. id, name, email</p>
  
  <pre><code>$user = User::where('id', Auth::id())-&gt;with(['community.roommates' =&gt; function ($query) 
          {
              $query-&gt;select('users.id', 'name', 'email');
          }])-&gt;first();
  </code></pre>
  
  <p>However my JSON response isn't what I expected, the id that is being returned appears to be the id of the community, even though I have specified 'users.id'</p>
  
  <pre><code>{
  "status": true,
  "data": {
  "id": 3,
  "name": "Foo Bar",
  "email": "test@test.com",
  "community": {
    "id": 1,
    "owner": 3,
    "title": "Home",
    "created_at": "2015-10-09 08:04:05",
    "updated_at": "2015-10-09 08:04:05",
    "roommates": [
      {
        "id": 1,
        "name": "Foo Bar 2",
        "email": "test@test.com"
      },
      {
        "id": 1,
        "name": "Foo Bar",
        "email": "test@test.com"
      }
    ]
  },
  "remember_token": "tprkiNOYbBiViwQkVcJMcwU8poZ1/00Uktmy7AQ+",
  "created_at": "2015-10-09 08:03:42",
  "updated_at": "2015-10-10 04:56:14"
  }
  }
  </code></pre>
  
  <p>As you can see the id on both users in the roommates array is 1, however the ids of those users are 2 and 3.</p>
  
  <p>Any ideas?</p>
  
  <p>I'm still feeling around with Laravel so I'm not sure where to go from here?</p>