Search

Showing 7 of 1,216 result(s)

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

max($key = null) The max method can be used to retrieve the maximum value of the given $key . By default, the $key is null and will function in a similar way to PHP's max function. The following code example highlights the usage of max without...

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

merge($items) The merge methods merges the given $items with the items in the collection. The merge method will replace any item in the original collection's items if a string key with the same value exists in the supplied $items . If the $items...

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

toArray The toArray method is similar to the all method in that it will return the underlying array that the collection instance is using. The difference, however, is that the toArray method will convert any object instance it can into arrays...

/blog/2016/11/30/laravel-collection-public-api-avg

avg($key = null) The avg method is a useful method for calculating the average of all items in the collection. The avg method defines an optional $key parameter, which can be used to specify what property of the collection should be averaged. If...

/blog/2016/11/30/laravel-collection-public-api-combine

combine($values) The combine method is used to combine the keys of the collection the method was called on with the values of another collection or array (supplied as an argument for $values ). This method is equivalent to using PHP's...

/blog/2016/11/30/laravel-collection-public-api-every

every($step, $offset = 0) The every method can be used to retrieve a subset of a collection based on each items distance from each other. It defines one required parameter $step and one optional parameter $offset . An argument supplied for $step...

/blog/2016/11/30/laravel-collection-public-api-except

except($keys) The except method will return all the key/value pairs in the collection where the keys in the collection are not in the supplied $keys array. Internally, this method makes a call to the Illuminate\Support\Arr:except($array, $keys)...