Overtrue\LaravelShoppingCart\Cart::count PHP 메소드

count() 공개 메소드

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)
리턴 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;
    }