title: Cast Laravel query results to class
body: <p>When creating a query using the syntax <code>DB::table('foo')</code>, it creates a generic class (stdClass). Is there any way to cast the resulting rows to a specific class?</p>
  
  <p>Here is some example code that should explain what I want to do:</p>
  
  <pre><code>$result = DB::table('foo')-&gt;get();
  $converted = (Foo) $result; // Not going to work
  </code></pre>
  
  <p>I want to cast all the (stdClass) objects of the array to the Foo class.</p>