Since Laravel 8.16, it is possible to split a collection into chunks in two different ways. The first one, that already existed, is the split method: This method breaks a collection into a specified amount of groups. As you can see, it tries to keep the amount of items in each group as close together as possible.
What if you want to split a collection into groups of similar size, and put the remainder in the last group?
It works almost the same, except that the collection will now be split into 2 groups of sizes 3, and 1 group with the remaining item.