Consider the following collection:
$cart = collect([ ['code' => '123', 'name' => 'Item 1', 'quantity' => 1], ['code' => '456', 'name' => 'Item 1', 'quantity' => 1] ]);
I want it so that if I were to push a new item with the same
123 I want to increase
quantity by 1.
push method just appends the new item at the end. How do I achieve this? Thanks.