laravel auth login with phone or email

Solutions on MaxInterview for laravel auth login with phone or email by the best coders in the world

showing results for - "laravel auth login with phone or email"
Yasmine
11 Feb 2020
1<?php
2
3namespace App\Http\Controllers\Auth;
4
5use App\Http\Controllers\Controller;
6use App\Providers\RouteServiceProvider;
7use Illuminate\Foundation\Auth\AuthenticatesUsers;
8use Illuminate\Http\Request;
9use Illuminate\Validation\ValidationException;
10
11class LoginController extends Controller
12{
13    /*
14    |--------------------------------------------------------------------------
15    | Login Controller
16    |--------------------------------------------------------------------------
17    |
18    | This controller handles authenticating users for the application and
19    | redirecting them to your home screen. The controller uses a trait
20    | to conveniently provide its functionality to your applications.
21    |
22    */
23
24    use AuthenticatesUsers;
25
26    /**
27     * Where to redirect users after login.
28     *
29     * @var string
30     */
31    protected $redirectTo = RouteServiceProvider::HOME;
32
33    /**
34     * Create a new controller instance.
35     *
36     * @return void
37     */
38    public function __construct()
39    {
40        $this->middleware('guest')->except('logout');
41    }
42
43    /**
44     * Get the failed login response instance.
45     *
46     * @param  \Illuminate\Http\Request  $request
47     * @return \Symfony\Component\HttpFoundation\Response
48     *
49     * @throws \Illuminate\Validation\ValidationException
50     */
51    protected function sendFailedLoginResponse(Request $request)
52    {
53        throw ValidationException::withMessages([
54            'username' => [trans('auth.failed')],
55        ]);
56    }
57
58    /**
59     * Get the login username to be used by the controller.
60     *
61     * @return string
62     */
63    public function username()
64    {
65        $login = request()->input('username');
66
67        if(is_numeric($login)){
68            $field = 'phone';
69        } elseif (filter_var($login, FILTER_VALIDATE_EMAIL)) {
70            $field = 'email';
71        } else {
72            $field = 'username';
73        }
74
75        request()->merge([$field => $login]);
76
77        return $field;
78    }
79}
80
81
queries leading to this page
laravel make default auth with phone not emailhow to change email to phone number in laravel authhow to change login from email to phone number in laravellaravel how to login user with phone numberlogin with phone number instead of email laravelemail or phone number auth laravellogin using phone number auth laravellarvel login by email or mobilelaravel change auth email to mobile number loginlaravel auth login through email or numberuse mobile number or email to login laravelauthenticate user with email and phone number laravellaravel login with email or phonelaravel auth login through email and numberlogin with username or email or phone laravel authlaravel auth login form mobile numberlaravel login with email or phonehow to login with phone and email in laravellaravel change auth from email to phone numberlogin with phone number and email laravellogin with email or phone number in laravelauthentication laravel mobile phoneuse phone instead of email laravel authlaravel change auth form email to phonelaravel login with phone number and passwordlaravel auth change email to phone for loginhow to check in registercontroller phone number uniqueemail or phone login laravel oauth 2ftokenlogin with username or phone or email in laravellaravel auth chenge email to phonelogin with mobile number or email laravellogin with phone and email in laravellogin with phone number instead of email in laravel 8laravel login with mobile or emaillaravel login phone number or emaillogin with email or phone number laravel 8login using either username or email or phone laravellaravel change auth email to mobile numberlaravel auth login exampleauth login using email or phone laravelllaravel login using both email and phonelaravel login via phone instead of emaillogin with email or phone number laravelhow to auth via mobile number in laravellaravel how to login user with phone number in authuse auth 28 29 3eattempt 28 29 to login with email or phone number laravellaravel authenication emaillaravel auth login with phonephone or email for authentication laravellaravel login with mobile number or emaillogin with email and phone laravellogin with email or phone number laravel 7how to authenicationfrom email to phone auth 3a 3aattempt in laravellaravel authentication tutorial email to phonelaravel mobile as login instead of emaillaravel login with phone emaillaravel auth login with phone or email laravel login with phone or emaillaravel auth login with phone or email