Search

Showing 7 of 1,216 result(s)

/blog/2018/04/22/laravel-5-collections-getting-the-number-of-elements-in-a-collection-with-count

The count method will return the number of elements contained within the collection's inner array; it is synonymous with PHP's count function.public function count();The count method is a straightforward method and simply returns the total number...

/blog/2018/04/22/laravel-5-collections-grouping-collection-elements-with-groupby

The groupBy method is used to group a collection based on a given value, represented by the $groupBy parameter. An argument passed to $groupBy can be a simple string, representing the value that the collection should be grouped by, or a callback...

/blog/2018/04/22/laravel-5-collections-mapping-collection-elements-and-reducing-to-a-single-dimension-with-flatmap

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 return a new, modified collection its return result.

/blog/2018/04/22/laravel-5-collections-merging-multiple-collection-values-with-merge

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 keys are...

/blog/2018/04/22/laravel-5-collections-modifying-collection-elements-with-transform

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 transform method will return a reference to the original collection instance....

/blog/2018/04/22/laravel-5-collections-paginating-collections-with-forpage

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" should be returned and $perPage , which is used to control the number of items that...

/blog/2018/04/22/laravel-5-collections-pair-the-values-of-a-collection-with-the-values-of-other-collections-with-zip

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 supplied as an argument. The zip method produces results that are similar to...