Skip to content

Commit 3585226

Browse files
mitchierichietaylorotwell
andauthoredJun 15, 2022
document append method on Eloquent Collection (laravel#7987)
* document append method on Eloquent Collection * formatting Co-authored-by: Taylor Otwell <[email protected]>
1 parent 378b3fa commit 3585226

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎eloquent-collections.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ In addition, the `Illuminate\Database\Eloquent\Collection` class provides a supe
6262

6363
<div class="collection-method-list" markdown="1">
6464

65+
[append](#method-append)
6566
[contains](#method-contains)
6667
[diff](#method-diff)
6768
[except](#method-except)
@@ -79,8 +80,17 @@ In addition, the `Illuminate\Database\Eloquent\Collection` class provides a supe
7980

8081
</div>
8182

83+
<a name="method-append"></a>
84+
#### `append($attributes)` {.collection-method .first-collection-method}
85+
86+
The `append` method may be used to indicate that an attribute should be [appended](/docs/{{version}}/eloquent-serialization#appending-values-to-json) for every model in the collection. This method accepts an array of attributes or a single attribute:
87+
88+
$users->append('team');
89+
90+
$users->append(['team', 'is_admin']);
91+
8292
<a name="method-contains"></a>
83-
#### `contains($key, $operator = null, $value = null)` {.collection-method .first-collection-method}
93+
#### `contains($key, $operator = null, $value = null)` {.collection-method}
8494

8595
The `contains` method may be used to determine if a given model instance is contained by the collection. This method accepts a primary key or a model instance:
8696

0 commit comments

Comments
 (0)
Please sign in to comment.