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

Solutions on MaxInterview for how to validate email or phone number single parameter request in laravel by the best coders in the world

showing results for - "how to validate email or phone number single parameter request in laravel"
Marius
05 Jan 2019
1protected function credentials(Request $request)
2        {
3          if(is_numeric($request->get('phone'))){
4            return ['phone'=>$request->get('phone'),'password'=>$request->get('password')];
5          }
6          elseif (filter_var($request->get('email'), FILTER_VALIDATE_EMAIL)) {
7            return ['email' => $request->get('email'), 'password'=>$request->get('password')];
8          }
9          return ['username' => $request->get('username'), 'password'=>$request->get('password')];
10        }