title: Validate array items with wheres from items
body: <h2>Context</h2>
  
  <p>I have two Order Models which are: <code>Order</code> and <code>OrderItem</code>.</p>
  
  <p>in OrderController I want to validate array of items. I checked <a href="https://laravel.com/docs/7.x/validation#validating-arrays" rel="nofollow noreferrer">Laravel array validation</a> and found out that I can use something like this:</p>
  
  <pre><code>    $customer_id = Auth::guard('api')-&gt;user()-&gt;id;
      $validate = validator($request-&gt;all(), [
          'address_id'    =&gt; 'required|numeric|exists:addresses,id,customer_id,' . $customer_id,
          'items.*.product_id'=&gt; 'required|numeric|exists:products,id',
      ]);
  </code></pre>
  
  <p>this is working for "static validation" </p>
  
  <hr>
  
  <h2>Goal</h2>
  
  <p>I want to add the following rule</p>
  
  <pre><code>'items.*.product_color_id'  =&gt; 'required|numeric|unique:order_items,product_color_id,NULL,id,product_size_id,' . $request-&gt;product_size_id . ',product_id,' . $request-&gt;product_id . '|exists:product_colors,id,product,' . $request-&gt;product_id,
  </code></pre>
  
  <p>the problem is how can I make  <code>$request-&gt;product_size_id</code> changes for each iteration in items??</p>
  
  <hr>
  
  <h2>Note</h2>
  
  <p>I thought about making them two controller <code>OrderController</code> and <code>OrderItemController</code> it will work this way but in this way the client has to send multiple requests (one for creating an Order and one for each item)</p>