[4.2] Fix groupBy() bug

As described here
https://github.com/laravel/framework/pull/4276#issuecomment-45563986 by
@JosephSilber