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.