Search
 
SCRIPT & CODE EXAMPLE
 

PHP

login with email or phone number laravel

    public function username()
    {
        $login = request()->input('username');

        if(is_numeric($login)){
            $field = 'phone';
        } elseif (filter_var($login, FILTER_VALIDATE_EMAIL)) {
            $field = 'email';
        } else {
            $field = 'username';
        }

        return $field;
    }
Comment

laravel auth login with phone or email

<?php

namespace AppHttpControllersAuth;

use AppHttpControllersController;
use AppProvidersRouteServiceProvider;
use IlluminateFoundationAuthAuthenticatesUsers;
use IlluminateHttpRequest;
use IlluminateValidationValidationException;

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::HOME;

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

    /**
     * Get the failed login response instance.
     *
     * @param  IlluminateHttpRequest  $request
     * @return SymfonyComponentHttpFoundationResponse
     *
     * @throws IlluminateValidationValidationException
     */
    protected function sendFailedLoginResponse(Request $request)
    {
        throw ValidationException::withMessages([
            'username' => [trans('auth.failed')],
        ]);
    }

    /**
     * Get the login username to be used by the controller.
     *
     * @return string
     */
    public function username()
    {
        $login = request()->input('username');

        if(is_numeric($login)){
            $field = 'phone';
        } elseif (filter_var($login, FILTER_VALIDATE_EMAIL)) {
            $field = 'email';
        } else {
            $field = 'username';
        }

        request()->merge([$field => $login]);

        return $field;
    }
}

Comment

PREVIOUS NEXT
Code Example
Php :: wordpress display post categories 
Php :: laravel collection toQuery 
Php :: wp_customize_image_control 
Php :: laravel append parameter to links 
Php :: search in laravel 8 
Php :: laravel blade routeIs 
Php :: php foreac 
Php :: php check version 
Php :: php connect strings 
Php :: How to create and access angular HTTP params in PHP 
Php :: get server ip php 
Php :: laravel pluck example 
Php :: Adding JavaScript to a Specific WordPress Page Using Code In Header 
Php :: laravel make model along with its controller and migration file 
Php :: where is phpinfo() 
Php :: validate contact us page 2021 php coding 
Php :: ini_set php 
Php :: merge collections laravel 
Php :: strict types php 
Php :: laravel realation with has 
Php :: get node id in twig drupal 
Php :: what does defined do in php 
Php :: laravel package for getID3() 
Php :: while true php 
Php :: laravel create controller 
Php :: php unique associative nested array by value 
Php :: composer autoload 
Php :: update php version wamp windows 
Php :: parsing html in php 
Php :: .htaccess Prevent access to php.ini 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =