Skip to content

Conversation

@jnoordsij
Copy link
Contributor

@jnoordsij jnoordsij commented Jan 16, 2023

Currently, the countBy method returns a static instance. However, the returned type is always of the form Collection<array-key, int>, so is never an Eloquent collection (in 'logical' sense). This can cause issues when chained with other collection methods, e.g. when doing something like $foo->countBy('bar')->merge($baz);.

Note: an alternative (and perhaps more accurate?) fix might be to change static to self on the base collection, though this is possibly a breaking change on those extending this class.

@taylorotwell taylorotwell merged commit dc78921 into laravel:9.x Jan 16, 2023
@jnoordsij jnoordsij deleted the fix-database-collection-countby-method branch January 16, 2023 19:30
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.

2 participants