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.

Eloquent: Collections 605<br />

Note: While most Eloquent collection methods return a new instance of an Eloquent<br />

collection, the pluck, keys, zip, collapse, flatten and flip methods return a base<br />

collection instance.<br />

Available Methods<br />

The Base Collection<br />

All Eloquent collections extend the base Laravel collection object; therefore, they inherit all of the<br />

powerful methods provided by the base collection class:<br />

A> #collection-method-list > p { A> column-count: 3; -moz-column-count: 3; -webkitcolumn-count:<br />

3; A> column-gap: 2em; -moz-column-gap: 2em; -webkit-column-gap: 2em; A> } A><br />

A> #collection-method-list a { A> display: block; A> }<br />

<br />

<br />

all chunk collapse contains count diff each every filter first flatten flip forget forPage get groupBy<br />

has implode intersect isEmpty keyBy keys last map merge pluck pop prepend pull push put random<br />

reduce reject reverse search shift shuffle slice sort sortBy sortByDesc splice sum take toArray toJson<br />

transform unique values where whereLoose zip<br />

<br />

Custom Collections<br />

If you need to use a custom Collection object with your own extension methods, you may override<br />

the newCollection method on your model:<br />

1

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

Saved successfully!

Ooh no, something went wrong!