Search

Showing 7 of 1,216 result(s)

/blog/2018/04/22/laravel-5-collections-adding-new-elements-to-a-collection-with-put

The put method is used to add a new item to the collection with a given $key and $value . The put method modifies the original Collection instance and returns a reference to it.The following code example highlights the usage of the put method:...

/blog/2018/04/22/laravel-5-collections-adding-values-to-a-collection-with-union

The union method will add the $items value to a copy of the existing collection. If there are key collisions between the collection instance and the provided $items , the elements from the collection instance will be used instead. The union method...

/blog/2018/04/22/laravel-5-collections-breaking-a-collection-into-a-specified-number-of-groups-with-split

The split method is similar to the chunk method in that it used to break a collection into a smaller number of collections. However, when using the split method, you specify the number of groups you would like the collection split into and it will...

/blog/2018/04/22/laravel-5-collections-calculating-the-average-value-of-a-collection-with-avg

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 no key is...

/blog/2018/04/22/laravel-5-collections-calculating-the-median-value-of-a-collection-with-median

In mathematics, the median value is the numeric value that separates the higher half a data sample from the lower half; the median value does not necessarily exist within the data set itself. The median method can be used to get the median value...

/blog/2018/04/22/laravel-5-collections-calculating-the-sum-of-a-collection-with-sum

The sum is a simple method that returns the sum of all items in a collection. It also defines a $callback parameter which can be used to tell the sum method which values of the collection should be added together. If no items are in the...