title: How to make email login case insensitive with Laravel 5.5 authentication
body: <p>When building my application, I used the Laravel authentication scaffolding by running <code>php artisan make:auth</code> which was great and saved me a lot of time.</p>
  <p>However, I am running into an issue with users not being able to login because they can't remember what case they used for their email when they originally signed up.</p>
  <p>For example, a user that signed up with <code>Myemail@domain.com</code> can not login with <code>myemail@domain.com</code>.</p>
  <p>I understand from my research that <em>technically</em> the part prior to the @ is case sensitive by <a href="https://stackoverflow.com/a/9808332/2611917">virtue of the spec</a>, and that the two emails above could, in theory, belong to two different people. In my situation though, I don't foresee that being enough of a likelihood that I would need to enforce this on login.</p>
  <p>I'm using a Postgres database so I'm looking to just replace the email database lookup in <code>Auth::attempt()</code> with <code>ilike</code> instead of <code>like</code> if possible. However, I can't for the life of me find where this is in the source and therefore have no idea how I would go about overwriting this.</p>
  <p>Tl;dr how do I override Laravel's default authentication to do email lookup in a case insensitive manner?</p>
  <h1>Solution</h1>
  <p>I ended up solving the issue by first taking @btl advice and implementing a mutator method on the email attribute. I didn't want to have to go through and change all the emails for existing users, and felt like in case I ever did run into an issue in which I'd like to have case-sensitivity back, I wanted a solution that could be undone easily.</p>
  <p><strong>app/User.php</strong></p>
  <pre><code>public function getEmailAttribute($value) {
      return strtolower($value);
  }
  </code></pre>
  <p><strong>app/Http/Controllers/Auth/LoginController.php</strong></p>
  <pre><code>protected function credentials()
  {
      $username = $this-&gt;username();
      $credentials = request()-&gt;only($username, 'password');
      if (isset($credentials[$username])) {
          $credentials[$username] = strtolower($credentials[$username]);
      }
      return $credentials;
  }
  </code></pre>
  <p>Unfortunately I couldn't figure out how to apply this same logic to the <code>ForgotPasswordController.php</code> but for now I'll live. Logging in seems to work regardless of email case now.</p>