Articles

Laravel 5 Collections: Finding an Element Key Conditionally With search

Laravel 5 The search method is used to search the collection for a given $value. If the given $value is found, the value's corresponding key is returned. If the $value is not found...

Laravel 5 Collections: Getting the First Collection Element With first

Laravel 5 The first method is used to get the first item in a collection, or to get the first item in a collection that matches a set of criteria. A $callback can be supplied to...

Laravel 5 Collections: Getting the Last Collection Element With last

Laravel 5 The last method is the logical opposite of the first method, and is used to get the last item in a collection, or to get the last item in a collection that matches a...

Laravel 5 Collections: Grouping Collection Elements With groupBy

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

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