I use Laravel UI for authentication. In my user table, I have a field called telephone. Can I use to log in the user with that telephone and password with Laravel UI Authentication? I tried to change the contents in App/Http/Controllers/Auth/LoginController.php
but couldn't figure out how this works. Really appreciate it if somebody could help. Thanks.
App/Http/Controllers/Auth/LoginController.php,
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::REDIRECT;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
You can put this on your LoginController
to override the Laravel default.
public function username()
{
return 'telephone';
}