/** * Adds the cartItem into the cart session * * @param CartItem $cartItem * * @return CartItem */ public function addItem(CartItem $cartItem) { $itemHash = $cartItem->generateHash(); if ($this->getItem($itemHash)) { $this->getItem($itemHash)->qty += $cartItem->qty; } else { $this->cart->items[] = $cartItem; } \Event::fire('laracart.addItem', $cartItem); $this->update(); return $cartItem; }