relation - Laravel Grouping by Eloquent Relationship - Stack Overflow

PHOTO EMBED

Wed Sep 28 2022 17:55:00 GMT+0000 (Coordinated Universal Time)

Saved by @eneki #php

 Sales::query()->where('this', $that)->get()->groupBy('product.name'); // OR

 Sales::query()->where('this', $that)->get()->groupBy('product.status.name');
content_copyCOPY

https://stackoverflow.com/questions/36468759/laravel-grouping-by-eloquent-relationship