- Add code to
LoginController.php
- Add
username
column tousers
table
Last active
July 24, 2017 06:38
-
-
Save njxqlus/7333115bf2a51916a9af3bbe66c5a639 to your computer and use it in GitHub Desktop.
Laravel Auth by email and username for web and api routes
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
<?php | |
/** | |
* Get the needed authorization credentials from the request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return array | |
*/ | |
protected function credentials(Request $request) | |
{ | |
$field = filter_var($request->get($this->username()), FILTER_VALIDATE_EMAIL) | |
? $this->username() | |
: 'username'; | |
return [ | |
$field => $request->get($this->username()), | |
'password' => $request->password, | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment