You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Effectively, the DB::raw call must be built into the select, and the groupBy() clause must be added.
One unfortunate thing I ran into is MySQL is in STRICT mode by default and thus every other "left join" relationship field must be included into the groupBy clause.
We might allow someone to specify these fields like so:
For count you can just call withCount on the model instance. Then in the table you can pass relationshipname_count. You can even add a new withCount method that can be used in component classes...
Currently only belongsTo and hasOne work out of the box.
The query builder can be modified to support hasMany relationships and return a count, sum, min, or max column/field.
The challenge is building this into the existing query builder.
Here is an example of how the end query might be built:
Effectively, the
DB::raw
call must be built into the select, and thegroupBy()
clause must be added.One unfortunate thing I ran into is MySQL is in STRICT mode by default and thus every other "left join" relationship field must be included into the groupBy clause.
We might allow someone to specify these fields like so:
where
.count
,.sum
,.max
,.min
etc are reserved keywords that the query builder will parse and understand how to build the query.The text was updated successfully, but these errors were encountered: