Laravel Collections – Introduction to Collections

Laravel Collections

Laravel Collections ( 11 Lessons )

Laravel Collections is one of the most powerful features of Laravel. Basically, collections are PHP arrays but it’s an Object Oriented approach to deal with PHP arrays.

see full series
  1. Laravel Collections – Introduction to Collections
  2. Laravel Collections – make Method
  3. Laravel Collections – wrap() and unwrap() Methods
  4. Laravel Collections – map() Method
  5. Laravel Collections – times() Method
  6. Laravel Collections – collapse() Method
  7. Laravel Collections – contains() & containsStrict() Methods
  8. Laravel Collections – each() Method
  9. Laravel Collection – Using toJson() Method
  10. Laravel Collection – Filtering Collection Items using where()
  11. Laravel Collection – Using splice() Method to Remove Items

Laravel Collections are one of the most powerful features of Laravel. Basically, collections are PHP arrays but it’s an Object Oriented approach to deal with PHP arrays.

Laravel collections offer over 90+ methods for manipulating the underlying data set. All methods are chainable, which means you can write code which is readable.

In this series, we will learn everything about the collection and what we can achieve with them. This post is an introduction to Laravel Collections, in the following posts, we will dive into the all methods Laravel Collections supplies with real examples.

Static Functions

Laravel’s Collection class ( Illuminate\Support\Collection ), provides some static functions which we can use to create new collection instances. Which are…

  • Collection::make();
  • Collection::wrap();
  • Collection::unwrap();
  • Collection::times();
  • Collection::proxy();

Public Functions

Laravel’s Collection class also expose the public API which provides many public methods that allow you to manipulate and transform the collections internal elements.

You can find all the public methods in the Illuminate\Support\Collection class or you can read the documentation for all function here.

We will be taking some real examples and use the collection methods to interact with the data.

So stay tuned for upcoming posts of this series.

Your little help will keep this site alive and help us to produce quality content for you.