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 :: get http host laravel 
Php :: php file get content replacing & with &amp; 
Php :: créer projet laravel 
Php :: check network connection php 
Php :: how to check number only in php 
Php :: date add one day php 
Php :: delete record php mysqli 
Php :: laravel remove apostrophe variables 
Php :: webuzo set upload limit 
Php :: php length of array 
Php :: laravel with trashed 
Php :: how to forget session in laravel 
Php :: php get random element from array 
Php :: echo post content by slug 
Php :: php string contains string 
Php :: get image name and extension laravel 
Php :: display nav menu in frontend using Wordpress 
Php :: array to table php 
Php :: laravel join query sum example 
Php :: Message: Too few arguments to function Admin::tindakan_vaksin1(), 1 passed in C:xampphtdocsloginsystemcoreCodeIgniter.php on line 532 and exactly 2 expected 
Php :: lluminateHttpExceptionsPostTooLargeException 
Php :: php load specific post id on language 
Php :: turn text file to string php 
Php :: convert matrix row to column php 
Php :: convert number to 2 decimal places in php 
Php :: jquery ajax 500 internal server error php 
Php :: HTML Snippets not working in .php files 
Php :: PHP | get client ip simple 
Php :: array_map class method 
Php :: PHP Deprecated: Function create_function() 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =