laravel/framework — pull request #5438 by benubird (2014-08-13 09:57:47+00:00)
Title: Make collection each method runnable fluently

I've adapted the collection each() method so that it can be used as part of a fluent query, to execute the same function over all elements of the collection and return the result.

For instance, say you want to call update(array('a' => $x)) over all the elements of a collection. Previously you would have to do this:

```
$collection->each(function($c) use($x){
$c->update(array('a' => $x));
});
````

Which is rather horribly untidy. But now you can do this:

$collection->each()->update(array('a' => 'b'));