diff --git a/collections.md b/collections.md index e41fecf89a..d75b217c07 100644 --- a/collections.md +++ b/collections.md @@ -1,7 +1,7 @@ # Collections - [Introduction](#introduction) -- [Creating Collections](#creating-collections) + - [Creating Collections](#creating-collections) - [Available Methods](#available-methods) @@ -17,23 +17,21 @@ The `Illuminate\Support\Collection` class provides a fluent, convenient wrapper }); -As you can see, the `Collection` class allows you to chain its methods to perform fluent mapping and reducing of the underlying array. In general, every `Collection` method returns an entirely new `Collection` instance. +As you can see, the `Collection` class allows you to chain its methods to perform fluent mapping and reducing of the underlying array. In general, collections are immutable, meaning every `Collection` method returns an entirely new `Collection` instance. -## Creating Collections +### Creating Collections As mentioned above, the `collect` helper returns a new `Illuminate\Support\Collection` instance for the given array. So, creating a collection is as simple as: $collection = collect([1, 2, 3]); -By default, collections of [Eloquent](/docs/{{version}}/eloquent) models are always returned as `Collection` instances; however, feel free to use the `Collection` class wherever it is convenient for your application. +The results of [Eloquent](/docs/{{version}}/eloquent) queries are always returned as `Collection` instances. ## Available Methods -For the remainder of this documentation, we'll discuss each method available on the `Collection` class. Remember, all of these methods may be chained for fluently manipulating the underlying array. Furthermore, almost every method returns a new `Collection` instance, allowing you to preserve the original copy of the collection when necessary. - -You may select any method from this table to see an example of its usage: +For the remainder of this documentation, we'll discuss each method available on the `Collection` class. Remember, all of these methods may be chained to fluently manipulating the underlying array. Furthermore, almost every method returns a new `Collection` instance, allowing you to preserve the original copy of the collection when necessary: