Laravel postgresql case insensitive

I am coding a web application using Laravel 4.1 and Postgresql as a database. The DB is case-sensitive, but I would like to make it case-insensitive, because, for example, when a user logs in, he must have access using the email address of upper case or lower case (for example, on any other site). However, the column for the password hash must be case sensitive, because the encryption method I use generates case-sensitive strings.

I use Eloquen ORM from Laravel, so I do not write requests directly.

How can I solve this problem?

Thanks in advance!

+4
source share
2 answers

A bit late, but it's pretty simple. Just use the "ILIKE" statement, for example

User::where("email", "ILIKE", $email)->get();
+8
source

I had this exact problem - my solution was to pretend to be case insensitive:

1) add one line to the appropriate methods to enter the entered email value in lower case

2) made a replacement in the database so that the letters were lowercase

3), make sure new letters are lowercase

Details:

1) The corresponding methods * are the main larvel code, so you redefine them with a new version that replaces the email value after checking the request: $ request ['email'] = Str :: lower ($ request ['email']);

  • : postLogin AuthenticatesUsers, AuthController.php postLogin
  • reset : postEmail postReset ResetsPassword, PasswordController.php

2) , email = ( );

3) , ( ) - - auth

, !

0

Source: https://habr.com/ru/post/1523499/


All Articles