Laravel array validation for unique attribute in array but not required to be unique in table
You can use distinct rule of laravel array
validation.
$validator = Validator::make(
['products' =>
['product_id' => 1, 'quantity' => 5],
['product_id' => 1, 'quantity' => 99],
['product_id' => 2, 'quantity' => 1],
],
['products.*.product_id' => 'distinct']
);
dd($validator->passes());