From d99905ffbf3bb4e38fab9a81488b9a96113acb43 Mon Sep 17 00:00:00 2001 From: Mahmoud Ramadan <48416569+mahmoudmohamedramadan@users.noreply.github.com> Date: Sat, 20 Dec 2025 05:10:01 +0200 Subject: [PATCH] Add mergeVisible and mergeHidden methods to docs Added documentation for mergeVisible and mergeHidden methods. --- eloquent-collections.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/eloquent-collections.md b/eloquent-collections.md index 21d08dae2f..978f5499ce 100644 --- a/eloquent-collections.md +++ b/eloquent-collections.md @@ -79,6 +79,8 @@ In addition, the `Illuminate\Database\Eloquent\Collection` class provides a supe [modelKeys](#method-modelKeys) [makeVisible](#method-makeVisible) [makeHidden](#method-makeHidden) +[mergeVisible](#method-mergeVisible) +[mergeHidden](#method-mergeHidden) [only](#method-only) [partition](#method-partition) [setAppends](#method-setAppends) @@ -231,6 +233,24 @@ The `makeHidden` method [hides attributes](/docs/{{version}}/eloquent-serializat $users = $users->makeHidden(['address', 'phone_number']); ``` + +#### `mergeVisible($attributes)` {.collection-method} + +The `mergeVisible` method [makes attributes visible](/docs/{{version}}/eloquent-serialization#hiding-attributes-from-json) that typically merges these attributes to the `$visible` array on each model in the collection: + +```php +$users = $users->mergeVisible(['middle_name']); +``` + + +#### `mergeHidden($attributes)` {.collection-method} + +The `mergeHidden` method [hides attributes](/docs/{{version}}/eloquent-serialization#hiding-attributes-from-json) that typically merges these attributes to the `$hidden` array on each model in the collection: + +```php +$users = $users->mergeHidden(['last_login_at']); +``` + #### `only($keys)` {.collection-method}