Skip to content

Commit

Permalink
added support for boolean keys in Collection::groupBy method
Browse files Browse the repository at this point in the history
The following PR adds support for boolean keys when used in ``groupBy`` method of ```\lluminate\Support\Collection``. Related to #18672 problem.
  • Loading branch information
linaspasv committed Apr 5, 2017
1 parent cebe9e8 commit 3d92f0d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ public function groupBy($groupBy, $preserveKeys = false)
}

foreach ($groupKeys as $groupKey) {
if (is_bool($groupKey)) {
$groupKey = (int) $groupKey;
}

if (! array_key_exists($groupKey, $results)) {
$results[$groupKey] = new static;
}
Expand Down

0 comments on commit 3d92f0d

Please sign in to comment.