title: laravel request validation rules pass parameter
body: <p>I'm going straight to the point here, I am wondering if it is possible to pass a parameter on a <code>validation rule</code> in Laravel.</p>
  
  <p>Here's my code:</p>
  
  <p>I need to pass the <code>$product-&gt;id</code> to the <code>ProductUpdateRequest</code> class.</p>
  
  <p>I've read some articles and to no avail can't pass a parameter into it. my other solution was to not use the validation rule class and do the validation directly on the controller by using <code>$request-&gt;validate[()]</code>. Since I can access the <code>$product-&gt;id</code> on the controller I can easily do the validation. but out of curiosity is there a way for me to pass the <code>$product-&gt;id</code> on the <code>validation class</code>?</p>
  
  <p><strong>CONTROLLER</strong></p>
  
  <pre><code>public function update(ProductUpdateRequest $request, Product $product)
      {
          $request['detail'] = $request-&gt;description;
          unset($request['description']);
          $product-&gt;update($request-&gt;all());
  
          return response([
              'data' =&gt; new ProductResource($product)
          ], Response::HTTP_CREATED);
      }
  </code></pre>
  
  <p><strong>VALIDATION RULE</strong></p>
  
  <pre><code>public function rules()
  {
      return [
          'name' =&gt; 'required|max:255|unique:products,name'.$product-&gt;id,
          'description' =&gt; 'required',
          'price' =&gt; 'required|numeric|max:500',
          'stock' =&gt; 'required|max:6',
          'discount' =&gt; 'required:max:2'
      ];
  }
  </code></pre>
  
  <p>Any suggestions/answers/help would be highly appreciated.</p>