title: Laravel formatting JSON output
body: <p>Is there a simple way to return more objects with different attribute name in JSON response? </p>
  
  <p>For example I have a <code>User</code> model which has attributes <code>name, password, xy</code> and if I do <code>return User::all();</code> I will return all users. But what if I want to return a list of custom objects where I will return JSON format like:</p>
  
  <pre><code>{
      'username' : ...
      'pass': ...
      'xyz' : ...
      'from_related_model' : ...
  }
  </code></pre>
  
  <p>so I will have name of fields returned differently then they are in DB, and also attach to each returned object an attribute from related model. </p>
  
  <p>I don't want to use mutators as I only want to return like that within one controller. I know I can traverse through object with foreach and make a new object by assigning values, and returning merged object. But is there a simpler way to do this?</p>