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: http://daylerees.com/codebright/eloquent-collections
Maybe someone else has more input.
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.
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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community