Laravel Collections – Introduction to 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- Laravel Collections – Introduction to Collections
- Laravel Collections – make Method
- Laravel Collections – wrap() and unwrap() Methods
- Laravel Collections – map() Method
- Laravel Collections – times() Method
- Laravel Collections – collapse() Method
- Laravel Collections – contains() & containsStrict() Methods
- Laravel Collections – each() Method
- Laravel Collection – Using toJson() Method
- Laravel Collection – Filtering Collection Items using where()
- 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.