Saturday, March 4, 2017

Handle unique email with Laravel using pqsql

I've always used MySQL, however, I recently used pgsql for a new project. I noticed that with the default Laravel validation rules for registration, that a user could sign up with an email that has been used previously, as long as the case was different. After looking into this, evidently, pgsql is a case-sensitive database. Therefore, test@email.com and Test@email.com are considered different. So the validation rule:

'email' => 'required|email|unique:users,email'

does not catch this case. I'm curious as to best practices for handling this. It could obviously be handled many different ways, just wondering how others deal with it.



via Clay

Advertisement