Redirect::back() 在 laravel 5.4 中不起作用

Redirect::back() is not working in laravel 5.4

if(count($data) == 1)
{
return view('home');
}
else {
// echo"ta-da";
Redirect::back()->with('message','username or password not Match!'); 
}

以上 Redirect::back() 函数在登录时不起作用。 如果我正在打印它显示的任何内容

您需要 return 重定向

要重定向,您必须使用 laravel 内置函数

return redirect()->back()->with('msg_name', 'your message');

或者您可以使用 route() 方法代替 back() 方法

return redirect()->route('your.route.name')->with('msg_name', 'your message');

重定向前使用return重定向到路由