title: Cart is showing same products for all users in laravel
body: <p>My cart is displaying same products for all users. I am using laravel built in auth and I have checked other answers where session is used. But I want to do it with auth.</p>
  <p><strong>CartController.php</strong></p>
  <pre><code>class CartController extends Controller
  {
      public function store(Request $request)
      {
          
          if (Auth::check()) {
  
              $cart = Cart::where('user_id', Auth::id())
                  -&gt;where('product_id', $request-&gt;product_id)
                  -&gt;first();
  
              if ($cart) {
                  $cart-&gt;increment('product_quantity');
                  $cart-&gt;save();
              } else {
                  Cart::create([
                      'user_id' =&gt; Auth::id(),
                      'product_id' =&gt; $request-&gt;product_id
                  ]);
              }
  
              session()-&gt;flash('success', 'Product has added to cart !!');
              return back();
          }
      }
  
  
      public function show()
      {
          
          if (Auth::check()) {
              $cart= Cart::all();
              return view('frontend.pages.cart')-&gt;with('carts', $cart);
          } else {
              session()-&gt;flash('status', 'No cart items added');
          }
      }
  </code></pre>
  <p>Please help with the code.</p>