Laravel: validation for unique username issue
- by T2theC
I have a noodle scratcher that I can't seem to figure out. I am validating for unique usernames and emails addresses. I have the following rules:
protected $rules = array(
'username' => 'required|min:4|unique:users,username',
'email' => 'email|unique:users,email',
'password' => 'min:6',
);
If I update a form that has the username (which is the same as it currently is), I get a The username has already been taken. error. If I do the same with the email, I get no error at all.
I know about adding the last param to the unique validation:
'unique:users,username,{{$id}}' or 'unique:users,username,'.$id
This doesn't work on the username. I get the same issue.
I can't figure out why this works for the email, but not the username.
Anyone had a similar issue or know where I am going wrong?
Many thanks,