Skip to content
Advertisement

Laravel grouping or taking from list in six

I’m not sure the title of this topic is correct, I apologize, you suppose I have this list which I get them from the database:

JavaScript

as you can see we can grouping them with the first part of each item that we can have that them in three groups, after grouping them I want to use foreach for each one item that’s there. I try to use the Laravel collection, but I can’t. Could you help me please how can I do that?

Advertisement

Answer

You could do the following:

JavaScript

But it might be more performant to add a group column to your model already.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement