O'Reilly logo

Learning Laravel's Eloquent by Francesco Malatesta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Using Collections to Enhance Results

Until now, I told you everything about models and how to create relationships between them. I explained you how to query your data and relationships and even to specify complex conditions and constraints. However, I have never told you anything about what Eloquent's outputs are. Yes, sometimes, I mentioned an array or just the word results. Don't worry; it wasn't wrong, but there is something more under the hood.

Well, in this chapter, I will discuss collections. When retrieving your results from a query (using, for instance, get() or all()), you are getting a collection. That's the right term to use.

Basically, you can think of a collection as an array of results but with some extra utility methods. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required