title: Building JSON object in desired way with Laravel
body: <p>Hi There Beste Collegues,</p>
  
  <p>I've having an problem building my json output structure well. 
  What i want is the following output: </p>
  
  <pre><code>{
    comments: {
          data: {
              created_at: "date",
              other: "etc",
          from: {
              username: "navidos",
              user_id: 1
           }
         }
      }
  }
  </code></pre>
  
  <p>But the way it is now build is:</p>
  
  <pre><code>{
      data: {
          description: "post description",
          status: "public",
          link: "http://www.bla.com",
          created_at: "2015-01-23 00:00:00",
      comments: [
      {
            text: "comment text 1",
            date: "2015-01-23 18:30:00",
            id: 1
       },
       {
            text: "comment text 2",
            date: "2015-01-23 18:35:00",
            id: 2
        },
        {
            text: "comment text 3",
            date: "2015-01-23 19:00:00",
            id: 3
         }
  ],
         user: {
             user_id: 1,
             username: "navid",
             profile_picture: null,
             bio: null
          }
      }
  }
  </code></pre>
  
  <p>The output i get is almost fine but i want the comment section in this output like the first output. I've tried everything with array_merge and array push but can't figure out what i'm doing wrong here. Is there anyone who can help me out. I'm using Laravel 4 and doing my Relations with the Eloquent ORM.</p>
  
  <p>So in my route i've now the following. </p>
  
  <pre><code>$post = Post::find($id);
  $postComments = $post-&gt;comments;
  $usersPost = $post-&gt;user;
  
  return Response::json(
     $data = array('data'=&gt;$post)
  );
  </code></pre>
  
  <p>I would be very grateful if someone can help me out with this. Tnx in advanced.  </p>