title: Check if value exists in database or not in laravel
body: <p>I have wishlist system where i save <code>user_id</code> and <code>product_id</code> and i want to check before save into wishlist table to see if user already saved this product in there or not.</p>
  
  <p>I found some question and articles about this but all of them only validate 1 value and not both, what I need is to check <code>auth::user()-&gt;id</code> and <code>product-&gt;id</code> both before saving.</p>
  
  <p>here is my store method:</p>
  
  <pre><code>  public function store(Request $request)
      {
        //Validating title and body field
        $this-&gt;validate($request, array(
            'user_id'=&gt;'required',
            'product_id' =&gt;'required',
          ));
  
        $wishlist = new Wishlist;
  
        $wishlist-&gt;user_id = $request-&gt;user_id;
        $wishlist-&gt;product_id = $request-&gt;product_id;
  
  
        $wishlist-&gt;save();
  
        return redirect()-&gt;back()-&gt;with('flash_message',
            'Item, '. $wishlist-&gt;product-&gt;title.' Added to your wishlist.');
      }
  </code></pre>
  
  <p>this is my form:</p>
  
  <pre><code>&lt;form action="{{route('wishlist.store')}}" method="post"&gt;
                                      {{csrf_field()}}
                                      &lt;input type="text" name="user_id" value="{{Auth::user()-&gt;id}}" hidden&gt;
                                      &lt;input type="text" name="product_id" value="{{$pdts-&gt;id}}" hidden&gt;
                                      &lt;button type="submit" class="btn btn-success"&gt;
                                          &lt;i class="fa fa-heart"&gt;&lt;/i&gt;
                                      &lt;/button&gt;
                                    &lt;/form&gt;
  </code></pre>
  
  <p>thanks.</p>