Overtrue\LaravelShoppingCart\Cart::update PHP Method

update() public method

Update the quantity of one row of the cart.
public update ( string $rawId, integer | array $attribute ) : Item | boolean
$rawId string The __raw_id of the item you want to update
$attribute integer | array New quantity of the item|Array of attributes to update
return Item | boolean
    public function update($rawId, $attribute)
    {
        if (!($row = $this->get($rawId))) {
            throw new Exception('Item not found.');
        }
        $cart = $this->getCart();
        $this->event->fire('cart.updating', [$row, $cart]);
        if (is_array($attribute)) {
            $raw = $this->updateAttribute($rawId, $attribute);
        } else {
            $raw = $this->updateQty($rawId, $attribute);
        }
        $this->event->fire('cart.updated', [$row, $cart]);
        return $raw;
    }