Laravel Collections – Introduction to Collections


This post is part of the series Laravel Collection

Other posts in this series:

  1. Laravel Collections – Introduction to Collections (Current)
  2. Laravel Collections – make Method
  3. Laravel Collections – wrap() and unwrap() Methods

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.

Continue reading this series: