06.10.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Upgrade Guide 39<br />

date format for serialized models, you may override the serializeDate(DateTime $date) method<br />

on your model. This method allows you to have granular control over the formatting of serialized<br />

Eloquent date fields without changing their storage format.<br />

The Collection Class<br />

The sort Method<br />

The sort method now returns a fresh collection instance instead of modifying the existing collection:<br />

1 $collection = $collection->sort($callback);<br />

The sortBy Method<br />

The sortBy method now returns a fresh collection instance instead of modifying the existing<br />

collection:<br />

1 $collection = $collection->sortBy('name');<br />

The groupBy Method<br />

The groupBy method now returns Collection instances for each item in the parent Collection. If<br />

you would like to convert all of the items back to plain arrays, you may map over them:<br />

1 $collection->groupBy('type')->map(function($item)<br />

2 {<br />

3 return $item->all();<br />

4 });<br />

The lists Method<br />

The lists method now returns a Collection instance instead of a plain array. If you would like to<br />

convert the Collection into a plain array, use the all method:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!