jeudi 20 février 2020

Laravel collection group by like category name

lets say I have a collection of objects fruits each having a shared color name.

I want to make it so the fruit is grouped by color name like so

Red
Red
Red
Green
Green
Red
Green

Becomes

Red
 Apple
 Strawberry 
 Cherry
 Cranberry

Green
  Grape
  Watermelon
  Pear

All help much appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire