You can group Eloquent results by any custom condition, here's how to group by first letter of user's name:
1$users = User::all()->groupBy(function($item) {2 return $item->name[0];3});
You can group Eloquent results by any custom condition, here's how to group by first letter of user's name:
1$users = User::all()->groupBy(function($item) {2 return $item->name[0];3});