laravel 目标 [App\Http\Requests\Request] 不可实例化

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37080429/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:44:39  来源:igfitidea点击:

Target [App\Http\Requests\Request] is not instantiable

laravel

提问by Qasim Ali

I am unable to understand why this error appears. I have created a function for user to give its credentials and log in.

我无法理解为什么会出现此错误。我为用户创建了一个函数来提供其凭据并登录。

Route of the function is

函数的路由是

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');
                }
            }
        }

回答by ItaloMoralesF

You will probably need this line of code in the top.

您可能需要顶部的这行代码。

use Illuminate\Http\Request;

If you have it, you can upload the project to a repository to help better?

如果你有的话,你可以把项目上传到存储库以更好地帮助吗?

回答by Achraf Khouadja

Try the above answer or this, both are the same

试试上面的答案或这个,两者都是一样的

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');
                    }
                }
            }