title: Laravel: How to get Models out of query results?
body: <p>Suppose I have a query that, among other things, returns user id's, this query was built using <code>DB::table()...</code> rather than using the models, so, as a result, I got a collection with arrays for each retrieved row, something like this:</p>
  
  <pre><code>user_id | calculated_data
  --------+----------------
        1 |     123
        2 |     111
        3 |     222
      ... |     ...
  </code></pre>
  
  <p>Supose I store this collection on a <code>$data</code> variable, of course if I do a <code>foreach ($data as $d) { $d-&gt;user_id ... }</code> will work.</p>
  
  <p>But I want this query to return something more like what the ORM does, so instead <code>user_id</code>s, return User models so I can do, for example, a <code>$data-&gt;user-&gt;name</code></p>
  
  <p>Can this be even done? if so, how?</p>