/**
  * Add product and quantity to cart
  *
  * TODO: check if the session_id and product_id exist in order to update and not create a new record
  *
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function addToCart(Request $request)
 {
     //get the product by url
     $product = $this->productRepo->findByUrl($request->get('url'));
     //create an array to store sessionCart data
     $sessionCartData = ['session_id' => $this->sessionId, 'product_id' => $product->id, 'price' => $request->get('price'), 'quantity' => $request->get('quantity')];
     // check if current user has this product in cart and update it
     $sessionCart = $this->sessionCartRepo->findBySessionIdAndProductId($this->sessionId, $product->id);
     if ($sessionCart) {
         $sessionCart->update($sessionCartData);
         return response()->json(['success' => 'Cart updated']);
     }
     //save cart
     $this->sessionCartRepo->create($sessionCartData);
     //return success
     return response()->json(['success' => 'Product added to cart!']);
 }