To force the validator to ignore unique
rule for a given id
you may pass the id
of that recored which is being validated, for example:
'keyword' => 'required|unique:keywords,keyword,10'
This, will not check uniqueness of the model if the id
is 10
, so when you are updating the model you need to pass the id
of the current model to ignore the unique rule on this model:
'keyword' => 'required|unique:keywords,keyword,' . $id
Since your rules variable is public static $rules
so you may access it from the controller and in this case before you run the validation in update method you need to change the rules for your keywords
field and I think you can change the rule like this (just set new rules for that field):
// Replace the Model with the name of your model within the controller
// update method before the validation takes place
Model::$rules['keyword'] = 'required|unique:keywords,keyword,' . $id;
Check the documentation.