Skip to content

Commit

Permalink
fix: collapseWithKeys on empty collection (#54290)
Browse files Browse the repository at this point in the history
* fix: collapseWithKeys on empty collection

* Update Collection.php

* Update Collection.php

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
benatoff and taylorotwell authored Jan 21, 2025
1 parent b504a73 commit 6e0e2cb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ public function collapse()
*/
public function collapseWithKeys()
{
if (! $this->items) {
return new static;
}

$results = [];

foreach ($this->items as $key => $values) {
Expand Down

0 comments on commit 6e0e2cb

Please sign in to comment.