0

Hello I use Laravel version 6.0.4. I use users provider and driver eloquent for retrieve the data from user_table. I use the model App\User

I would like to write in database email like: UpperCase@mail.com and retrieve when I write in login username like : uppercase@mail.com. Finally, I would like to recordind in database like the user put in register form an can retrieve on uppercase ou lowercase.

I already wrote this code in : AuthenticatesUsers. I looked this tips from stackoverflow :

How to make email login case insensitive with Laravel 5.5 authentication How to make email login case insensitive with Laravel 5.5 authentication

But it work only if the database email was write on uppercase.

I would like to know where is the folder where eloquent retrieve email from database for use strtolower on the email field.

I looked in Illuminate\Contracts\Auth\UserProvider or DatabaseUserProvider but I found nothing.

Thank you so much for your help.

Here my code

 protected function credentials()
 {
            $username = $this->username(); //take the email (see function username())
            $credentials = request()->only($username, 'password'); //take userrname(email) from page login
            if (isset($credentials[$username])) { //Verify if the user entered username
                $credentials[$username] = strtolower($credentials[$username]); 
            }
            return $credentials;

       
Joc380
  • 25
  • 7
  • 1
    What Database are you using? On `MySQL`, you can write the email as `ExAmPlE@wHaTeVeR.cOm`, and it'll work with `example@whatever.com`. The raw query like `SELECT * FROM users WHERE email = 'ExAmPlE@wHaTeVeR.cOm';` returns the correct row too. So by default, it's case-insensitive, and you'd have to use `WHERE BINARY(email) = ...` to override that behaviour. – Tim Lewis Mar 18 '21 at 20:56
  • Thank you for your help. I used Vertica. It is aproximatly like Oracle. I use Eloquent like driver. The problem is I don't know where is the file or class where Eloquent execute his request. – Joc380 Mar 19 '21 at 12:46
  • Haven't heard of that DB. Are you using a package like https://github.com/mixartemev/dbal-vertica-driver to handle configuration? – Tim Lewis Mar 19 '21 at 13:50
  • No. You have to on website of Vertica and you can download a free database version. I thikn is vertica communauty. One of a probleme is community is restricted. When you have a problem, it is hard to have help. Also, some request structure are not like normal SQL. I used because my company use it. If not, I use mySql, the best database. – Joc380 Mar 22 '21 at 12:59
  • Finally, I decide to do samething than How to make email login case insensitive with Laravel 5.5 authentication. Laravel recording on lowercase in database and with the code of credentials, the user can enter is username on lower or upper, no mather. I thought is the more logical solution and the best. – Joc380 Mar 22 '21 at 13:01

0 Answers0