Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

Group by the non-aggregated selected column(s).

Last updated 1 year ago.
0

Group by messes up count query. It has (nearly) nothing to do with Eloquent.

4 that you get, is beers count for first brewery. Result of you query is not a single row with count, but many (2 in your case) rows with beers per brewery count. The only thing Eloquent is doing here is returning just 1 row from the result set (because of count method)

Last updated 1 year ago.
0

Got it !

Thank you, I thought the count was not a MySQL count, but a php count for the size of the array returned. Now that makes sense, thanks to you both.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Doh-a doh-a Joined 20 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.