public function scopeOfCart($query, $cart)
    {
        $cartId = is_object($cart) ? $cart->id : $cart;

        return $query->where('cart_id', $cartId);
    }
public function scopeOfCart($query, $cart)
    {
        $cartId = is_object($cart) ? $cart->id : $cart;

        return $query->where('cart_id', $cartId);
    }
public function scopeOfCart ( $ query , $ cart ) { $ cartId = is_object ( $ cart ) ? $ cart -> id : $ cart ; return $ query -> where ( 'cart_id' , $ cartId ) ; }
Scope to query items of a cart

@param \Illuminate\Database\Eloquent\Builder $query
@param mixed $cart Cart object or cart id

@return \Illuminate\Database\Eloquent\Builder
Scope to query items of a cart