title: Laravel Collection ( not Eloquent) to Object
body: <p>Is it possible to return an object from a Laravel collection ?</p>
  
  <pre><code>$originalArr =[
      'foo' =&gt;'bar',
     'foo2' =&gt; 'bar2'
  
  ]
  
  $coll=collect($originalArr)-&gt;reject(function($item){
  
      // do something
  });
  
  
  // now I can convert the collection to an array... but to an object?
  $arr = $coll-&gt;toArray();
  
  // array
  dump($arr)
  
  // but what if I want to have an object ?  I have to do 
  $object  = (object) $arr;
  
  
  dump ($object) 
  
  
  //So you can access the attributes like  $object-&gt;foo.
  </code></pre>
  
  <p>But this seems fairly stupid... First make a collection , then convert to an array and then once again convert to an object.</p>
  
  <p>Is there a more efficient way?</p>
  
  <p><strong>Edit</strong> </p>
  
  <p>Alright I input an array I will get an array back , but what If I input an object ?</p>
  
  <pre><code>$origalObject = (object) $originalArr =[
          'foo' =&gt;'bar',
         'foo2' =&gt; 'bar2'
  
      ];
  </code></pre>
  
  <p>... And do the same , laravel will give me back an array.
  And I have to cast it again to an Object.  That is a lot of extra code if dealing with objects. Sure I can build a simple function for this .. but why is it not build in Laravel?</p>