Last active
July 20, 2018 03:14
-
-
Save Ademking/6cfac0b38bc2a9eaf333336e9be129c9 to your computer and use it in GitHub Desktop.
❤️ Laravel : (5.5) : Allow login using username or email
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in app/Http/Controllers/Auth/LoginController.php | |
<?php | |
/* | |
* code ... | |
*/ | |
use AuthenticatesUsers; | |
protected function credentials(Request $request) | |
{ | |
$login = request()->input('email'); | |
// Check whether username or email is being used | |
$field = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; | |
return [ | |
$field => $request->get('email'), | |
'password' => $request->password | |
]; | |
} | |
/* | |
* code ... | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment