Search

Showing 7 of 1,216 result(s)

/blog/2016/11/29/laravel-collection-public-api-count

count The count method is a straightforward method and simply returns the total number of items in the collection. The count method returns an integer.

/blog/2016/11/29/laravel-collection-public-api-diff

diff($items) The diff method is used to determine which items in the collection are not present in the supplied $items collection. $items can be be either an array, or another instance of Collection . The diff method returns a new instance of...

/blog/2016/11/29/laravel-collection-public-api-diff_keys

diffKeys($items) The diffKeys method is similar to the diff method. It is used to determine which items whose keys in the collection are not present in the supplied $items collection's keys. $items can be either an array, or another instead of...

/blog/2016/11/29/laravel-collection-public-api-each

each(callable $callback) The each method accepts a $callback which will be called on each item in the collection. If the $callback returns false , the each method will break from its iterator and return a reference back to the original Collection...

/blog/2016/11/29/laravel-collection-public-api-filter

filter(callable $callback = null) The filter method applies a filter to the collection. An optional $callback can be supplied to the filter method. If no $callback is supplied to the filter method, any value in the collection that evaluates to...

/blog/2016/11/29/laravel-collection-public-api-first

first(callable $callback = null, $default = null) The first method is used to get the first item in a collection, or to get the first item in a collection that matches a set of criteria. A $callback can be supplied to return the first item in the...

/blog/2016/11/29/laravel-collection-public-api-flatten

flatten The flatten method will return a new Collection instance representing a flattened version of the original collection's items. The flatten method internally makes use of the Illuminate\Support\Arr::flatten($array) helper method. The flatten...