Laravel Collections Guide
Setting Up A Collection Playground
On this special episode, we are answering your questions regarding the setup that I have been using during the course to play with collection. So here it is, from scratch using a console command.
contains() and containsStrict()
In this episode we are tackling, the method contains() and containsStrict(). Two very similar methods but we dissect the difference.
diff(), diffAssoc() and diffKeys()
In this episode we are tackling three similar methods, the diff(), diffAssoc() and diffKeys(). Come along as we explore these Laravel collection methods.
diffUsing(), diffAssocUsing() and diffKeysUsing()
In this episode we are tackling three similar methods, the diffUsing(), diffAssocUsing() and diffKeysUsing(). Come along as we explore these advanced Laravel collection methods.
mapToDictionary() and mapToGroups()
In this episode, we are tackling mapToDictionary and the very similar mapToGroups. Watch this video to see the difference between those two similar methods.
where() and whereStrict()
In this episode, we are tackling where() and the very similar whereStrict(). Watch this video to see the difference between those two similar methods.
whereBetween() and whereNotBetween()
In this episode, we are tackling the recently added whereBetween() and the very similar whereNotBetween(). Watch this video to see the difference between those two similar methods.
whereIn() and whereInStrict()
In this episode, we are tackling whereIn() and the very similar whereInStrict(). Watch this video to see the difference between those two similar methods.
whereNotIn() and whereNotInStrict()
In this series, we take a look at each of the available methods in the Laravel Collection class and dive deep through examples in explaining what it does.
In this episode, we are tackling whereInstanceOf(). Watch this video to learn more about filtering by class name.
Wrap is a utility method that helps us to normalize parameters when writing our own custom functions. Learn all about it on this lesson along with a refactor using the splat or spread operator.
Unwrap is a utility method that helps us to normalize parameters when writing our own custom functions. Learn all about it on this lesson along with a refactor using the splat or spread operator.
Let's take a look at the filter method, this very useful method is extremely powerful and easy to use. Learn all about it in this lesson.
In this lesson, we take a look at the pluck method and explore how to pluck multiple values, the answer might surprise you.
In this episode, we take a look at the filtering method of firstWhere(), a convenient shortcut method that allows a where() and first() call, all in one method. We also take a look at an upcoming change in Laravel 5.8.
When it comes to a long chain of method calls and transformations, sometimes, you may need to preview each step. In today's lesson, we talk about the dd() method and it does, just that.
Let's talk about the zip() method today, this method allows you to take 2 collections and zip them together. We'll also be looking at a trick for offsetting values.
For single dimension collections there's no easier way to put it in a specific order. Learn all about custom sorting, in this episode of the Laravel Collections Guide.
When you need to sort a multi dimensional collection or array, let sortBy() assist. In this episode, we tackle it from basic to a custom implementation with string manipulation.
When the need arises to pivot your collections by a field, the groupBy() method comes to the rescue. For more advanced grouping, check out the callback features.
At first glance, the first( ) method is very simple but it has some hidden functionality that you may not have known about. In this episode, we explore the advanced callback and default features.
Come along as we explore that advanced features of the last() method. The last() method, at first glance, seems like a very simple method but as we dive deeper, we discover the callback and default functionalities.
isEmpty() & isNotEmpty()
In this episode, we are tackling the isEmpty() and isNotEmpty() methods in the Laravel Collection class. Explore the two methods step by step to get a deep understanding of how they work.
Today, we are taking a look at reverse(), the reverse() method takes a collection and reverses all of the elements in it.
When you need to limit the number of items in your collection, the take() method will "take" any given number of items and return a new collection.
The nth() method is a great helper for filtering your collection by a given number of steps. It even has an extra parameter to offset the collection.
When you need to filter a collection by a key or a set of keys, the only() method is what you are looking for. Pass in 'null' to bypass the entire operation. Learn all about it in this video.
each() & eachSpread()
Passing a collection to a callback function is easy when you use the each() method. For better code readability, use the eachSpread().
Did you know you can dump a collection at any point? Learn all about dump() in this lesson.
For the ultimate control of your factory creations, reach for the static times() method. This method will allow you to run a callback X amount of times.
all() vs. toArray()
Today, we are comparing the difference between the all() method and the toArray() method. These two similar methods have one slight difference in the way they handle child collections. Learn all about it in this lesson.