Laravel Collections – Introduction to Collections

Laravel Collections

Laravel Collections ( 8 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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Using Scopes in Laravel
Sometimes you run into a situation when you have to reuse some of the conditions more often. Laravel provides a...