diff --git a/src/Illuminate/Support/Arr.php b/src/Illuminate/Support/Arr.php index e7f0ad0..72a9c0f 100644 --- a/src/Illuminate/Support/Arr.php +++ b/src/Illuminate/Support/Arr.php @@ -69,13 +69,23 @@ public static function collapse($array) */ public static function crossJoin(...$arrays) { - return array_reduce($arrays, function ($results, $array) { - return static::collapse(array_map(function ($parent) use ($array) { - return array_map(function ($item) use ($parent) { - return array_merge($parent, [$item]); - }, $array); - }, $results)); - }, [[]]); + $results = [[]]; + + foreach ($arrays as $index => $array) { + $append = []; + + foreach ($results as $product) { + foreach ($array as $item) { + $product[$index] = $item; + + $append[] = $product; + } + } + + $results = $append; + } + + return $results; } /** @@ -380,6 +390,10 @@ public static function pluck($array, $value, $key = null) } else { $itemKey = data_get($item, $key); + if (is_object($itemKey) && method_exists($itemKey, '__toString')) { + $itemKey = (string) $itemKey; + } + $results[$itemKey] = $itemValue; } }