我的认证::尝试不起作用。 但是我的注册表格数据将存储在User数据库中,并且我还应用了auth :: check(),它也无法正常工作。
这是控制器
public function showLoginform(Request $request){
$this->validate($request,[
'email' => 'required',
'password' => 'required',
]);
$user_data = array(
'email' => $request->get('email'),
'password' => $request->get('password')
);
if(Auth::attempt($user_data)){
//return \redirect::to("logged in successfuly");
echo "yes match";
} else{
echo "not match";
// return "oopps something wrong";
}
}
这是我的模特
类用户扩展了Authenticateable { 使用可通知的;
protected $table="users";
protected $fillable = [ 'name', 'email', 'password', 'phonenumber' , 'profession' , 'images' ];
protected $hidden = [
'password', 'remember_token',
];
}
答案 0 :(得分:0)
使用$ request-> input代替$ request-> get
public function showLoginform(Request $request){
$this->validate($request,[
'email' => 'required',
'password' => 'required',
]);
$user_data = array(
'email' => $request->input('email'),
'password' => $request->input('password')
);
if(Auth::attempt($user_data)){
//return \redirect::to("logged in successfuly");
echo "yes match";
} else{
echo "not match";
// return "oopps something wrong";
}
}