Skip to content

Commit 0c6dab7

Browse files
authored
Sync Eloquent collections documentation
1 parent a9b3f78 commit 0c6dab7

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

eloquent-collections.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<a name="introduction"></a>
88
## Introduction
99

10-
All multi-result sets returned by Eloquent are an instance of the `Illuminate\Database\Eloquent\Collection` object, including results retrieved via the `get` method or accessed via a relationship. The Eloquent collection object extends the Laravel [base collection](/docs/{{version}}/collections), so it naturally inherits dozens of methods used to fluently work with the underlying array of Eloquent models.
10+
All multi-result sets returned by Eloquent are instances of the `Illuminate\Database\Eloquent\Collection` object, including results retrieved via the `get` method or accessed via a relationship. The Eloquent collection object extends the Laravel [base collection](/docs/{{version}}/collections), so it naturally inherits dozens of methods used to fluently work with the underlying array of Eloquent models.
1111

1212
Of course, all collections also serve as iterators, allowing you to loop over them as if they were simple PHP arrays:
1313

@@ -28,7 +28,7 @@ However, collections are much more powerful than arrays and expose a variety of
2828
return $user->name;
2929
});
3030

31-
> **Note:** While most Eloquent collection methods return a new instance of an Eloquent collection, the `pluck`, `keys`, `zip`, `collapse`, `flatten` and `flip` methods return a [base collection](/docs/{{version}}/collections) instance.
31+
> **Note:** While most Eloquent collection methods return a new instance of an Eloquent collection, the `pluck`, `keys`, `zip`, `collapse`, `flatten` and `flip` methods return a [base collection](/docs/{{version}}/collections) instance. Likewise, if a `map` operation returns a collection that does not contain any Eloquent models, it will be automatically cast to a base collection.
3232
3333
<a name="available-methods"></a>
3434
## Available Methods
@@ -51,15 +51,21 @@ All Eloquent collections extend the base [Laravel collection](/docs/{{version}}/
5151
<div id="collection-method-list" markdown="1">
5252

5353
[all](/docs/{{version}}/collections#method-all)
54+
[average](/docs/{{version}}/collections#method-average)
55+
[avg](/docs/{{version}}/collections#method-avg)
5456
[chunk](/docs/{{version}}/collections#method-chunk)
5557
[collapse](/docs/{{version}}/collections#method-collapse)
58+
[combine](/docs/{{version}}/collections#method-combine)
5659
[contains](/docs/{{version}}/collections#method-contains)
5760
[count](/docs/{{version}}/collections#method-count)
5861
[diff](/docs/{{version}}/collections#method-diff)
62+
[diffKeys](/docs/{{version}}/collections#method-diffkeys)
5963
[each](/docs/{{version}}/collections#method-each)
6064
[every](/docs/{{version}}/collections#method-every)
65+
[except](/docs/{{version}}/collections#method-except)
6166
[filter](/docs/{{version}}/collections#method-filter)
6267
[first](/docs/{{version}}/collections#method-first)
68+
[flatMap](/docs/{{version}}/collections#method-flatmap)
6369
[flatten](/docs/{{version}}/collections#method-flatten)
6470
[flip](/docs/{{version}}/collections#method-flip)
6571
[forget](/docs/{{version}}/collections#method-forget)
@@ -74,7 +80,13 @@ All Eloquent collections extend the base [Laravel collection](/docs/{{version}}/
7480
[keys](/docs/{{version}}/collections#method-keys)
7581
[last](/docs/{{version}}/collections#method-last)
7682
[map](/docs/{{version}}/collections#method-map)
83+
[max](/docs/{{version}}/collections#method-max)
84+
[median](/docs/{{version}}/collections#method-median)
7785
[merge](/docs/{{version}}/collections#method-merge)
86+
[min](/docs/{{version}}/collections#method-min)
87+
[mode](/docs/{{version}}/collections#method-mode)
88+
[only](/docs/{{version}}/collections#method-only)
89+
[pipe](/docs/{{version}}/collections#method-pipe)
7890
[pluck](/docs/{{version}}/collections#method-pluck)
7991
[pop](/docs/{{version}}/collections#method-pop)
8092
[prepend](/docs/{{version}}/collections#method-prepend)
@@ -98,10 +110,13 @@ All Eloquent collections extend the base [Laravel collection](/docs/{{version}}/
98110
[toArray](/docs/{{version}}/collections#method-toarray)
99111
[toJson](/docs/{{version}}/collections#method-tojson)
100112
[transform](/docs/{{version}}/collections#method-transform)
113+
[union](/docs/{{version}}/collections#method-union)
101114
[unique](/docs/{{version}}/collections#method-unique)
102115
[values](/docs/{{version}}/collections#method-values)
103116
[where](/docs/{{version}}/collections#method-where)
104117
[whereLoose](/docs/{{version}}/collections#method-whereloose)
118+
[whereIn](/docs/{{version}}/collections#method-wherein)
119+
[whereInLoose](/docs/{{version}}/collections#method-whereinloose)
105120
[zip](/docs/{{version}}/collections#method-zip)
106121

107122
</div>
@@ -132,4 +147,4 @@ If you need to use a custom `Collection` object with your own extension methods,
132147
}
133148
}
134149

135-
Once you have defined a `newCollection` method, you will receive an instance of your custom collection anytime Eloquent returns a `Collection` instance of that model. If you would like to use a custom collection for every model in your application, you should override the `newCollection` method on a model base class that is extended by all of your models.
150+
Once you have defined a `newCollection` method, you will receive an instance of your custom collection anytime Eloquent returns a `Collection` instance of that model. If you would like to use a custom collection for every model in your application, you should override the `newCollection` method on a base model class that is extended by all of your models.

0 commit comments

Comments
 (0)