8 months ago

How to Validate Unique Rules on an update

Posted 8 months ago by chrisgrim

Hi, I am trying to validate my model for uniqueness but I am running into an issue when I try to update. I created a new UpdateRequest.php file.

return [
            'website' => 'required|unique:organizers',

When I update with my form it gives me the error "website":["The website has already been taken."]}}. I guess this makes sense because in my database there is that website, even though it is on the model I am trying to update. I looked into the laravel docs and from what I can see they only show how to ignore the rule

Forcing A Unique Rule To Ignore A Given ID
'email' => 'unique:users,email_address,10'

I don't want to ignore this rule in the case where I do update the website and it conflicts with another entry. Thanks

Please sign in or create an account to participate in this conversation.