Cart Management

All of these operations return full cart data with items.

Add to cart

/**
 * Add to cart
 *
 * @return json
 */
 public function addToCart()
{
    return Product::addToCart(request('productId'));
}

Remove from cart

/**
 * Remove from cart
 *
 * @return json
 */
public function removeFromCart()
{
    return cart()->removeAt(request('cartItemIndex'));
}

Increment/decrement quantity of a cart item

/**
 * Increment cart item quantity
 *
 * @return json
 */
public function incrementCartItem()
{
    return cart()->incrementQuantityAt(request('cartItemIndex'));
}

/**
 * Decrement cart item quantity
 *
 * @return json
 */
public function decrementCartItem()
{
    return cart()->decrementQuantityAt(request('cartItemIndex'));
}

Clear cart

/**
 * Clear Cart
 *
 * @return json
 */
public function clearCart()
{
    return cart()->clear();
}

Fetching Cart Data