我无法理解为什么会出现此错误。我已经为用户创建了一个函数来提供其凭据并登录。
功能的路线是
Route::any('login','UserController@authenticate');
public function authenticate(Request $request) {
if($request->isMethod('post')) {
$email = $request->input('email');
$password = $request->input('password');
if(Auth::attempt(array('email' => $email, 'password' => $password), true)) {
return redirect()->intended('publicPages.home_startup')->withErrors('Congratulations! You are logged in');
} else {
return redirect()->intended('publicPages.login')->withErrors('Sorry! Login Failed');
}
}
}
答案 0 :(得分:23)
您可能需要在顶部使用这行代码。
use Illuminate\Http\Request;
如果有,可以将项目上传到存储库以帮助更好吗?
答案 1 :(得分:0)
尝试上述答案或两者,两者都是相同的
public function authenticate(Illuminate\Http\Request $request) {
if($request->isMethod('post')) {
$email = $request->input('email');
$password = $request->input('password');
if(Auth::attempt(array('email' => $email, 'password' => $password), true)) {
return redirect()->intended('publicPages.home_startup')->withErrors('Congratulations! You are logged in');
} else {
return redirect()->intended('publicPages.login')->withErrors('Sorry! Login Failed');
}
}
}