Laravel Lumen 调用未定义函数 App\Http\Controllers\back()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30819157/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel Lumen Call to undefined function App\Http\Controllers\back()
提问by wobsoriano
Hello so I am working on my own authentication system using Laravel's lumen and getting the error Call to undefined function App\Http\Controllers\back()
whenever I try to login with wrong credentials. This what my function looks like in my controller:
您好,我正在使用 Laravel 的 lumen 开发我自己的身份验证系统,并且Call to undefined function App\Http\Controllers\back()
每当我尝试使用错误的凭据登录时都会收到错误消息。这是我的函数在我的控制器中的样子:
public function loglink(Request $request) {
$input = $request->all();
$user = array(
'username' => $input['username'],
'password' => $input['password']
);
if (Auth::attempt($user)) {
$user = Auth::user();
return view('auth.welcome', compact('user'));
} else {
return back()->withInput();
}
}
Is there something I need to include/call in my controller?
我需要在控制器中包含/调用某些内容吗?
回答by Limon Monte
You can use back()
shortland in Laravel only for now. For Lumen you need to add redirect()
:
您back()
现在只能在 Laravel 中使用shortland。对于流明,您需要添加redirect()
:
return redirect()->back()->withInput();
Read more: http://lumen.laravel.com/docs/responses#redirects