public function add($entity, $quantity)
    {
        if ($this->itemExists($entity)) {
            $cartItemIndex = $this->items->search($this->cartItemsCheck($entity));

            return $this->incrementQuantityAt($cartItemIndex, $quantity);
        }

        $this->items->push(CartItem::createFrom($entity, $quantity));

        event(new CartItemAdded($entity));

        return $this->cartUpdates($isNewItem = true);
    }
public function add($entity, $quantity)
    {
        if ($this->itemExists($entity)) {
            $cartItemIndex = $this->items->search($this->cartItemsCheck($entity));

            return $this->incrementQuantityAt($cartItemIndex, $quantity);
        }

        $this->items->push(CartItem::createFrom($entity, $quantity));

        event(new CartItemAdded($entity));

        return $this->cartUpdates($isNewItem = true);
    }
public function add ( $ entity , $ quantity ) { if ( $ this -> itemExists ( $ entity ) ) { $ cartItemIndex = $ this -> items -> search ( $ this -> cartItemsCheck ( $ entity ) ) ; return $ this -> incrementQuantityAt ( $ cartItemIndex , $ quantity ) ; } $ this -> items -> push ( CartItem :: createFrom ( $ entity , $ quantity ) ) ; event ( new CartItemAdded ( $ entity ) ) ; return $ this -> cartUpdates ( $ isNewItem = true ) ; }
Adds an item to the cart.

@param Illuminate\Database\Eloquent\Model
@param int Quantity
@return array
Adds an item to the cart .