public function setCartItemQuantity($cartItemId, $newQuantity)
    {
        $items = collect(session($this->itemsKey));

        $items = $items->map(function ($item) use ($cartItemId, $newQuantity) {
            if ($item['id'] == $cartItemId) {
                $item['quantity'] = $newQuantity;
            }

            return $item;
        });

        session([$this->itemsKey => $items]);
    }
public function setCartItemQuantity($cartItemId, $newQuantity)
    {
        $items = collect(session($this->itemsKey));

        $items = $items->map(function ($item) use ($cartItemId, $newQuantity) {
            if ($item['id'] == $cartItemId) {
                $item['quantity'] = $newQuantity;
            }

            return $item;
        });

        session([$this->itemsKey => $items]);
    }
public function setCartItemQuantity ( $ cartItemId , $ newQuantity ) { $ items = collect ( session ( $ this -> itemsKey ) ) ; $ items = $ items -> map ( function ( $ item ) use ( $ cartItemId , $ newQuantity ) { if ( $ item [ 'id' ] == $ cartItemId ) { $ item [ 'quantity' ] = $ newQuantity ; } return $ item ; } ) ; session ( [ $ this -> itemsKey => $ items ] ) ; }
Updates the quantity of the cart item.

@param int Id of the cart item
@param int New quantity to be set
@return void
Updates the quantity of the cart item .