/** * Loads the cart and refreshes the cookie */ private function loadCart($withRelationships = FALSE) { // Look for a cart cookie if (!($this->cookie = Cookie::get('bedard_shop_cart'))) { return FALSE; } // Load the cart with relationships if ($withRelationships) { $this->cart = CartModel::where('key', $this->cookie['key'])->whereNull('order_id')->with('items.inventory.product.discounts')->with('items.inventory.product.categories.discounts')->with(['items' => function ($item) { $item->inCart(); }])->find($this->cookie['id']); if ($this->cart && !is_null($this->cart->coupon_id)) { $this->cart->load('coupon'); } } else { $this->cart = CartModel::where('key', $this->cookie['key'])->whereNull('order_id')->find($this->cookie['id']); } // Refresh the cookie $this->refreshCartCookie(); }