Laravel 5.5.29 introduced the ability to group a collection on multiple levels. In a new post on his blog, Christopher Rumpel demonstrates the new feature with some good examples.

https://christoph-rumpel.com/2018/01/groupby-multiple-levels-in-laravel