title: Laravel: JSON and pivot table
body: <p>Sorry about the non-explanatory title but I could not come up with a descriptive one. </p>
  
  <p>I've got the following 3 tables:
   - games 
   - platforms
   - games_platforms</p>
  
  <p>And I've got 2 Models in Laravel for both Platform and Game.</p>
  
  <pre><code>public function games() 
  {
      return $this-&gt;belongsToMany('App\Game', 'games_platforms')-&gt;withPivot('release_date');
  }
  
  public function platforms() 
  {
      return $this-&gt;belongsToMany('App\Platform', 'games_platforms')-&gt;withPivot('release_date');
  }
  </code></pre>
  
  <p>Now this works like a charm, I get a JSON string with all the information in the 3 tables, like this.</p>
  
  <pre><code>[{
      "id": 1,
      "name": "Borderlands",
      "short_description": "",
      "created_at": null,
      "updated_at": null,
      "platforms": [{
          "id": 4,
          "name": "PC",
          "pivot": {
              "game_id": 1,
              "platform_id": 4,
              "release_date": "2016-03-03"
          }
      }]
  }]
  </code></pre>
  
  <p>Now my problem is as follows. I don't want to show the whole 'pivot' information, just the 'release_date', like this: </p>
  
  <pre><code>"platforms": [{
          "id": 4,
          "name": "PC",
          "release_date": "2016-03-03"
  </code></pre>
  
  <p>Is there an easy way in Laravel to do such a thing? As far as I can see right now, looking at other posts, is to either write a function that turns the json into an array and I can arrange it then. Or I can write my own query instead of letting Laravel do all that.</p>
  
  <p>Hope you guys can help me with this issue. Thanks!</p>