Oct 24, 2018
0
Level 1
Validation: unique fields in an request array
Hello everyone,
I have a list of products a user can edit. When he saves his changes I want to validate his entries. The field 'artNo' has to be unique in the products table. Normally I would just use the following rule:
$rules = [
'item.*.artNo' => ['required',
Rule::unique('products')->ignore($id)]
];
But now I have an array with multiple IDs. Is there a way to give this rule the ID of the product which is currently validating?
My request looks like this
$request->item[$idOfTheProduct]['artNo'];
Best, Sascha
Please or to participate in this conversation.