Skip to content

[5.4] Add "flatMap" to collection higher order proxies - #18529

Merged
taylorotwell merged 1 commit into
laravel:5.4from
JosephSilber:flat-map-proxy
Mar 28, 2017
Merged

[5.4] Add "flatMap" to collection higher order proxies#18529
taylorotwell merged 1 commit into
laravel:5.4from
JosephSilber:flat-map-proxy

Conversation

@JosephSilber

Copy link
Copy Markdown
Contributor

No description provided.

@calebporzio

calebporzio commented Mar 28, 2017

Copy link
Copy Markdown
Contributor

I second this. Very useful for cases such as:
Getting an array of all the related models from a group of models

$commentCount = $posts->flatMap->comments->count()

right now the only way is overly verbose

$commentCount = $posts->map->comments->flatten()->count()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants