Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Laravel 5.4.29 changes (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
besologic authored Jul 19, 2017
1 parent fbe5680 commit 15251e7
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/Illuminate/Support/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 15251e7

Please sign in to comment.