title: Laravel Eloquent Convert user_id to user info
body: <p>I've some relationships in my Model classes.<br></p>
  
  <hr>
  
  <p>Consume this relationship:<br>
  We've <code>Post()</code> model which store our posts data. Each post in this table has a <code>user_id</code> column that has one to many relationship with <code>User()</code> Mode (the author of the post)</p>
  
  <pre><code>class User extends Model {
      public function posts()
      {
          return $this-&gt;hasMany('App\Post');
      }
  }
  </code></pre>
  
  <pre><code>class Post extends Model {
  
      public function user()
      {
          return $this-&gt;belongsTo('App\User');
      }
  }
  </code></pre>
  
  <p>So when i want to return my post with elequent, I'll get something like this:</p>
  
  <pre><code>{
      "user_id": 1,
      "title": "Foo name",
      "body": "Foo body",
  },
  {
      "user_id": 1,
      "title": "Bar name",
      "body": "another Bar body",
  }
  </code></pre>
  
  <p>But i want to get something like this:</p>
  
  <pre><code>{
      "user_id": 1,
      "user": {
          'name'=&gt; 'John',
          'last'=&gt; 'Maco',
       },
      "title": "Foo name",
      "body": "Foo body",
  },
  {
      "user_id": 1,
      "user": {
          'name'=&gt; 'John',
          'last'=&gt; 'Maco',
       },
      "title": "Bar name",
      "body": "another Bar body",
  }
  </code></pre>