If you turn off strict mode for this one query only, does it work or do you get an error.
How to write the eloquent query without using DB::raw so that it doesn't have to put MySQL strict mode to false.
How to write the eloquent query to select the max value without using DB::raw and writing in pure eloquent so that it doesn't have to put MySQL strict mode to false. Means any alternative to write, DB::raw('max(price) as price') without making MySQL strict mode to false.
Item::join('product', 'item.id', '=', 'product.item_id')
->select(['item_id', 'item.title',DB::raw('max(price) as price')])
->where('product.user_id', '=', $user->id)
->groupBy('product.item_id')
->get();
See the manual and read about strict modes.
https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html
And you can turn off strict mode for one query only if needed. It isn't a security problem.
https://laracasts.com/discuss/channels/guides/turn-off-only-full-group-by-for-just-one-query-guide
The only other solution is rewrite your query to avoid the error. Also using raw on an aggregate is pretty standard.
Make sure to select all fields used in query.
Please or to participate in this conversation.