JavaScript
1
Вклад в тег
$test = $collect
->groupBy('product')->map(function ($item) {
return $item[0];
})->toArray();
$test_2 = $collect_2
->groupBy('product')->map(function ($item) {
return $item[0];
})->toArray();
foreach ($test as $key => $item) {
$test_3[$key] = array_merge($test[$key] ?? [], $test_2[$key] ?? []);
}