laravel/framework — pull request #3117 by Anahkiasen (2014-01-03 16:25:48+00:00)
Title: Add Collection::groupBy

This allows to group a Collection's items by one of their attributes :

```php
$comments = array(
['name' => 'foo', 'rating' => 1],
['name' => 'bar', 'rating' => 2],
['name' => 'baz', 'rating' => 1],
);

$results = $comments->groupBy('rating');

array(
1 => array(
['name' => 'foo', 'rating' => 1],
['name' => 'baz', 'rating' => 1],
),
2 => array(
['name' => 'bar', 'rating' => 2],
),
);
```

I seemed to remember something similar being proposed by couldn't find anything in the issues or on Collection/helpers, so I must have imagined it.