title: Laravel Eloquent get all in single key value pair
body: <p>I have two tables <code>posts</code> and <code>post_metas</code> with the schema as below:</p>
  
  <pre><code>POSTS
  +------------+------------------+
  | Field      | Type             |
  +------------+------------------+
  | id         | int(10) unsigned |
  | title      | varchar(255)     |
  | content    | longtext         |
  
  
  POST_METAS
  +------------+------------------+
  | Field      | Type             |
  +------------+------------------+
  | id         | int(10) unsigned |
  | post_id    | int(10) unsigned |
  | key        | varchar(255)     |
  | value      | longtext         |
  </code></pre>
  
  <p>using a simple one to many relationship, i get this output</p>
  
  <pre class="lang-json prettyprint-override"><code>[
    {
      "id": 1,
      "title": "Dibbert LLC",
      "content": null,
      "post_metas": [
        {
          "key": "code",
          "value": "YSRSLBZ7"
        },
        {
          "key": "agent_id",
          "value": "32"
        }
      ]
    }
  ]
  </code></pre>
  
  <p>I am wondering if it is possible to have the post metas as an object not an array, like this instead:</p>
  
  <pre class="lang-json prettyprint-override"><code>[
    {
      "id": 1,
      "title": "Dibbert LLC",
      "content": null,
      "post_metas": {
          "code": "YSRSLBZ7",
          "agent_id": "32"
        }
    }
  ]
  </code></pre>