Group by the non-aggregated selected column(s).
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)
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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community