Articles

Laravel 5 Collections: Reducing a Collection Into a Collection of Key/Array-Value Pairs With mapToDictionary

Laravel 5 In computing, a dictionary is a data structure where there exists a relationship between a single key and a value, or a list multiple values; examples of these are...

Laravel 5 Collections: Reducing a Collection Into a Collection of Key/Collection-Value Pairs With mapToGroups

Laravel 5 The mapToGroups method is similar to the mapToDictionary method, in that the mapToGroups method allows you take a collection of data and reduce it such that the final...

Laravel 5 Collections: Reducing a Collection to One Element With reduce

Laravel 5 The reduce method is to reduce a collection into only one item. It does this by iterating over the collection and applying the $callback function on each element. The...

Laravel 5 Collections: Reducing a Multi-Dimensional Collection to a Single Dimension Losing Keys With flatten

Laravel 5 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...

Laravel 5 Collections: Removing a Portion of a Collection With splice

Laravel 5 The splice method is a useful method; it is often used to remove a portion of a collection and return the removed section. It defines three parameters: $offset, $length and...