Laravel updateOrCreate很多

I was wondering if there is a way to do an updateOrCreate on many items.

Here's what I have:

    foreach ($request->input('inventories') as $group_id => $inventory) {
        foreach ($inventory as $inventory_id => $quantity) {
            if (is_null($quantity) || $quantity == 0) {
                continue;
            }

            $event->eventInventory()->updateOrCreate([
                'group_id' => $group_id,
                'inventory_id' => $inventory_id
            ], [
                'quantity' => $quantity ?? 0
            ]);
        }
    }

Is there a better or cleaner way of doing this?