public function refreshAllItemsData()
    {
        $keepDiscount = true;

        $this->items->transform(function ($item) use (&$keepDiscount) {
            $freshEntity = $item->modelType::findOrFail($item->modelId);

            $cartItem = CartItem::createFrom($freshEntity, $item->quantity);

            if ($cartItem->price != $item->price) {
                $keepDiscount = false;
            }

            $item->name = $cartItem->name;
            $item->price = $cartItem->price;
            $item->image = $cartItem->image;

            return $item;
        });

        $this->cartDriver->updateItemsData($this->items);

        $this->updateTotals($keepDiscount);
        $this->cartDriver->updateCart($this->id, $this->data());

        return $this->toArray();
    }
public function refreshAllItemsData()
    {
        $keepDiscount = true;

        $this->items->transform(function ($item) use (&$keepDiscount) {
            $freshEntity = $item->modelType::findOrFail($item->modelId);

            $cartItem = CartItem::createFrom($freshEntity, $item->quantity);

            if ($cartItem->price != $item->price) {
                $keepDiscount = false;
            }

            $item->name = $cartItem->name;
            $item->price = $cartItem->price;
            $item->image = $cartItem->image;

            return $item;
        });

        $this->cartDriver->updateItemsData($this->items);

        $this->updateTotals($keepDiscount);
        $this->cartDriver->updateCart($this->id, $this->data());

        return $this->toArray();
    }
public function refreshAllItemsData ( ) { $ keepDiscount = true ; $ this -> items -> transform ( function ( $ item ) use ( & $ keepDiscount ) { $ freshEntity = $ item -> modelType :: findOrFail ( $ item -> modelId ) ; $ cartItem = CartItem :: createFrom ( $ freshEntity , $ item -> quantity ) ; if ( $ cartItem -> price != $ item -> price ) { $ keepDiscount = false ; } $ item -> name = $ cartItem -> name ; $ item -> price = $ cartItem -> price ; $ item -> image = $ cartItem -> image ; return $ item ; } ) ; $ this -> cartDriver -> updateItemsData ( $ this -> items ) ; $ this -> updateTotals ( $ keepDiscount ) ; $ this -> cartDriver -> updateCart ( $ this -> id , $ this -> data ( ) ) ; return $ this -> toArray ( ) ; }
Refreshes all items data.

@return array
Refreshes all items data .