📜  如何在 laravel 中验证电子邮件或电话号码单参数请求 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:21.126000             🧑  作者: Mango

代码示例1
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')];
        }