Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to validate email or phone number single parameter request in laravel

protected function credentials(Request $request)
        {
          if(is_numeric($request->get('phone'))){
            return ['phone'=>$request->get('phone'),'password'=>$request->get('password')];
          }
          elseif (filter_var($request->get('email'), FILTER_VALIDATE_EMAIL)) {
            return ['email' => $request->get('email'), 'password'=>$request->get('password')];
          }
          return ['username' => $request->get('username'), 'password'=>$request->get('password')];
        }
 
PREVIOUS NEXT
Tagged: #validate #email #phone #number #single #parameter #request #laravel
ADD COMMENT
Topic
Name
8+4 =