This commit is contained in:
rahul shukla 2019-09-09 18:34:02 +05:30
parent 8d578c3720
commit f49e25ea1f
1 changed files with 18 additions and 0 deletions

View File

@ -79,6 +79,12 @@ class ProductForm extends FormRequest
$inputs = $this->all();
if (isset($inputs['variants'])) {
foreach ($inputs['variants'] as $key => $variant) {
$this->rules['variants'.'.'.$key.'.'.'sku'] = ['unique:products,sku,' . $key, new \Webkul\Core\Contracts\Validations\Slug];
}
}
$product = $this->product->find($this->id);
$attributes = $product->attribute_family->custom_attributes;
@ -131,4 +137,16 @@ class ProductForm extends FormRequest
return $this->rules;
}
/**
* Custom message for validation
*
* @return array
*/
public function messages()
{
return [
'variants.*.sku.unique' => 'The sku has already been taken.',
];
}
}