Support the ongoing development of →
posted 10 years ago
Last updated 1 year ago.

Collections are a new feature of Laravel 4. You can certainly do without them but in certain cases they can really cut down the amount of code you need to write when you need to work with a set of records.

To understand the benefits I recommend you check out Dayle Rees' Code Bright chapter on Collections:

Maybe someone else has more input.

Last updated 1 year ago.

thanks for that - yup, Dayle has done a good job of explaining what they are, I have his book and have read the section in Collections. I can see that they could cut down code, but they appear to add some complexity.

It would be brilliant if some one could explain the benefit of using them.

Last updated 1 year ago.

Collections have nothing to do with sql queries. They are just a container for data. It just so happens that eloquent (which does have something to do with sql) uses collections to store the result sets.

You can look at Collections as a fancy replacement for arrays. Look at the Collection class in the code to see what functionality collections give you.

Last updated 1 year ago.

Sign in to participate in this thread!


Your banner here too?

vincej vincej Joined 10 Apr 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.