well you cant get the same output, because there is only 3 columns available now.
type_id, category_id, date
right?
you could add price but then you need to add that 2 the group by. that will get you the results your looking for 'here'. but if there is another entry like:
4 | 5 | 10 | 150.00 | 2017-01-03
then you'll get 3 rows back. (cause price has 2 possible values.
Yes, I need to get the latest products where type and category are unique. Grouping by price won't work for this scenario. Maybe groupBy is not the way to go with this.
Product::select(DB::raw('price, type_id, category_id, max(created_at) as date'))
->orderBy('date')
->groupBy('type_id')
->groupBy('category_id')
->get();
I got it working by adding a boolean helper column to my table. I was trying to avoid this but it will actually help me in a number of places. Much easier.