return [
'$itemsByMart' => $itemsByMart,
'$customProductsByMart' => $customProductsByMart
];
{
"1": [
{...},
{...},
{...}
],
"2": [
{...}
],
"3": [
{...}
]
}
$results = collect();
$itemsByMart->each(function ($item, $key) use ($customProductsByMart, $results) {
$push = $customProductsByMart->has($key) ? $item->mergeRecursive($customProductsByMart->get($key)) : $item;
$results[$key] = $push;
});
$customProductsByMart->each(function ($item, $key) use ($results) {
if (!$results->has($key)) {
$results[$key] = $item;
}
});