Problem with unique rule in validation on Update?



I have a validation rule in my validation like this

ean13: ‘unique:products,id,productId|required_if:active_bol_be|required_if:active_bol_nl|max:20’

Problem is that the rule still is checked on update products ?
productId is a known var with the id in it ?

What am i doing wrong ?



You’re missing ‘fieldname’

Should be:
ean13: 'unique:products,ean13,id,productId|...'

In otherwords, ean13 must be unique within the products table, unless the id field = the provided value.

See: unique(tableName, [fieldName], [ignoreField], [ignoreValue])


Still does not work !


actually… sorry that should be:

ean13: `unique:products,ean13,id,${productId}|...`

productId’s value has to get populated into the rule.


And… Still NOT work !


And you’re certain that productId contains the value of the id field of the product being updated?

Something must not be right. need more info


Looked agaib to it and… it works !

I forget the backticks !

Thanks a lot !