app/Helper/Cart.php
/**
     * Add new item in cart or increment quantity if he's already exists.
     *
     * @param ShopItem $item
     */
Add new item in cart or increment quantity if he's already exists.
Add new item in cart or increment quantity if he ' s already exists .
public function addItem(ShopItem $item)
    {
        if ($this->items->has($item->id)) {
            $this->items->get($item->id)->quantity += $item->quantity;
        } else {
            $this->items->put($item->id, $item);
        }
        $this->save();
    }
public function addItem ( ShopItem $ item ) { if ( $ this -> items -> has ( $ item -> id ) ) { $ this -> items -> get ( $ item -> id ) -> quantity += $ item -> quantity ; } else { $ this -> items -> put ( $ item -> id , $ item ) ; } $ this -> save ( ) ; }
Add new item in cart or increment quantity if he's already exists.
Add new item in cart or increment quantity if he ' s already exists .