File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
src/Illuminate/Database/Eloquent Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -580,6 +580,28 @@ public function makeVisible($attributes)
580580 return $ this ->each ->makeVisible ($ attributes );
581581 }
582582
583+ /**
584+ * Merge the given, typically visible, attributes hidden across the entire collection.
585+ *
586+ * @param array<array-key, string>|string $attributes
587+ * @return $this
588+ */
589+ public function mergeHidden ($ attributes )
590+ {
591+ return $ this ->each ->mergeHidden ($ attributes );
592+ }
593+
594+ /**
595+ * Merge the given, typically hidden, attributes visible across the entire collection.
596+ *
597+ * @param array<array-key, string>|string $attributes
598+ * @return $this
599+ */
600+ public function mergeVisible ($ attributes )
601+ {
602+ return $ this ->each ->mergeVisible ($ attributes );
603+ }
604+
583605 /**
584606 * Set the visible attributes across the entire collection.
585607 *
Original file line number Diff line number Diff line change @@ -545,6 +545,22 @@ public function testMakeVisibleRemovesHiddenFromEntireCollection()
545545 $ this ->assertEquals ([], $ c [0 ]->getHidden ());
546546 }
547547
548+ public function testMergeHiddenAddsHiddenOnEntireCollection ()
549+ {
550+ $ c = new Collection ([new TestEloquentCollectionModel ]);
551+ $ c = $ c ->mergeHidden (['merged ' ]);
552+
553+ $ this ->assertEquals (['hidden ' , 'merged ' ], $ c [0 ]->getHidden ());
554+ }
555+
556+ public function testMergeVisibleRemovesHiddenFromEntireCollection ()
557+ {
558+ $ c = new Collection ([new TestEloquentCollectionModel ]);
559+ $ c = $ c ->mergeVisible (['merged ' ]);
560+
561+ $ this ->assertEquals (['visible ' , 'merged ' ], $ c [0 ]->getVisible ());
562+ }
563+
548564 public function testSetVisibleReplacesVisibleOnEntireCollection ()
549565 {
550566 $ c = new Collection ([new TestEloquentCollectionModel ]);
You can’t perform that action at this time.
0 commit comments