Articles

Laravel 5 Collections: Mapping Collection Elements and Reducing to a Single Dimension With flatMap

Laravel 5 The flatMap method is used in the same way as the map method but will collapse the resulting collection. The flatMap method does not modify the original collection; it will...

Laravel 5 Collections: Modifying Collection Elements With transform

Laravel 5 The transform is identical to the map method, but instead of returning a new Collection instance, the transform method will modify the original collection instance. The...

Laravel 5 Collections: Paginating Collections With forPage

Laravel 5 The forPage method is used to implement pagination over collections. The forPage defines two parameters: $page, which is used to tell the collection which "page"...

Laravel 5 Collections: Pair the Values of a Collection With the Values of Other Collections With zip

Laravel 5 The zip method is used to merge the values of two collections. The first collection will be the collection that the zip method was invoked on, the second collection is...

Laravel 5 Collections: Randomizing Element Order With shuffle

Laravel 5 The shuffle method is used to rearrange the items of the array in a random distribution. The shuffle method will return a new collection and will not modify the original...