Overtrue\LaravelShoppingCart\Cart::count PHP Method

count() public method

Get the number of items in the cart.
public count ( boolean $totalItems = true ) : integer
$totalItems boolean Get all the items (when false, will return the number of rows)
return integer
    public function count($totalItems = true)
    {
        $items = $this->getCart();
        if (!$totalItems) {
            return $items->count();
        }
        $count = 0;
        foreach ($items as $row) {
            $count += $row->qty;
        }
        return $count;
    }