$usernameinput = Input::get('email');
$password = Input::get('password');
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
if (Auth::attempt(array($field => $usernameinput, 'password' => $password, 'active' => 1), true)) {
//success
}else{
//error
}
我正在尝试登录那些用户名/电子邮件有效并且用户类型为1,2,3,4的用户如何设置其中type = [1,2,3,4];在尝试laravel
答案 0 :(得分:0)
尝试此代码可能对您有所帮助
$user=User::where('email','=',$usernameinput)->first()
if (Auth::attempt(array($field => $usernameinput, 'password' => $password, 'active' => 1,'type'=>in_array($user->type,[1,2,3,4])), true)) {
//success
}else{
//error