From 4bbc2c4ab3505ec1c11343c2a8c9bec767c6e571 Mon Sep 17 00:00:00 2001 From: Jonathan Goode Date: Tue, 6 Aug 2024 12:19:42 +0100 Subject: [PATCH 1/2] Expand `forget()` example to include removing multiple keys at once --- collections.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/collections.md b/collections.md index e579487629..618b46f10a 100644 --- a/collections.md +++ b/collections.md @@ -1072,12 +1072,14 @@ The `forget` method removes an item from the collection by its key: $collection = collect(['name' => 'taylor', 'framework' => 'laravel']); + // Forget a single key... $collection->forget('name'); - - $collection->all(); - // ['framework' => 'laravel'] + // Forget multiple keys... + $collection->forget(['name', 'framework']); + // [] + > [!WARNING] > Unlike most other collection methods, `forget` does not return a new modified collection; it modifies the collection it is called on. From 5fdf9e6c80f701df43569a28b25db7ed5000712c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 6 Aug 2024 08:49:57 -0500 Subject: [PATCH 2/2] Update collections.md --- collections.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/collections.md b/collections.md index 618b46f10a..c8c9198a7d 100644 --- a/collections.md +++ b/collections.md @@ -1074,10 +1074,12 @@ The `forget` method removes an item from the collection by its key: // Forget a single key... $collection->forget('name'); + // ['framework' => 'laravel'] // Forget multiple keys... $collection->forget(['name', 'framework']); + // [] > [!WARNING]