protected function cart() { // Make sure that the cart instance is stored $instance = $this->cart->getInstance(); if (!($cart = $this->user->cart()->whereInstance($instance)->first())) { $cart = $this->user->cart()->create(compact('instance')); } return $cart; }
/** * Returns the user cart associated to the given cart instance. * * @param string $instance * @return \App\Models\Cart */ protected function cart($instance) { if (!($cart = $this->user->cart()->whereInstance($instance)->first())) { $cart = $this->user->cart()->create(compact('instance')); } return $cart; }