![javascript](https://habrastorage.org/r/w120/webt/59/cc/76/59cc7600c78a2239379574.jpeg)
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] ?? []);
}