php 类 App\Http\Controllers\Auth\Request 不存在。Laravel 5.3
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39763082/
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
Class App\Http\Controllers\Auth\Request does not exist. Laravel 5.3
提问by Andrew Vanusi
I am using Laravel 5.3 My ForgotPasswordController looks like that:
我正在使用 Laravel 5.3 我的 ForgotPasswordController 看起来像这样:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Base\BaseController;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends BaseController
{
use SendsPasswordResetEmails;
public function __construct()
{
$this->middleware('guest');
}
public function showLinkRequestForm()
{
$title = $this->title;
$appName = $this->appName;
$action = $this->action;
return view('password.forgotPassword')->with(compact('title', 'appName', 'action'));
}
}
ResetPasswordController code :
重置密码控制器代码:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Base\BaseController;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends BaseController
{
use ResetsPasswords;
public function __construct()
{
$this->middleware('guest');
}
public function showResetForm(Request $request, $token = null)
{
return view('passwords.resetPassword')->with(
['token' => $token, 'email' => $request->email]
);
}
public function reset(Request $request)
{
$this->validate($request, [
'token' => 'required',
'password' => 'required|confirmed|min:6',
]);
// Here we will attempt to reset the user's password. If it is successful we
// will update the password on an actual user model and persist it to the
// database. Otherwise we will parse the error and return the response.
$response = $this->broker()->reset(
$this->credentials($request), function ($user, $password) {
$this->resetPassword($user, $password);
}
);
// If the password was successfully reset, we will redirect the user back to
// the application's home authenticated view. If there is an error we can
// redirect them back to where they came from with their error message.
return $response == Password::PASSWORD_RESET
? $this->sendResetResponse($response)
: $this->sendResetFailedResponse($request, $response);
}
}
My Admin Route :
我的管理路线:
Route::group(['namespace' => 'Auth'], function() {
Route::get('/forgotpassword/reset', 'ForgotPasswordController@showLinkRequestForm');
Route::post('/forgotpassword/email', 'ForgotPasswordController@sendResetLinkEmail');
Route::get('/password/reset/{token}', 'ResetPasswordController@showResetForm');
Route::post('/password/reset', 'ResetPasswordController@reset');
});
BaseController Code :
基本控制器代码:
<?php
namespace App\Http\Controllers\Base;
use App\Http\Controllers\Controller;
class BaseController extends Controller
{
protected $appName = 'Stackoverflow';
protected $title = 'Welcome to Stackoverflow';
protected $action;
}
I can send the link to my email, but once I click the link/button. It throws an error like above. Any idea ?
我可以将链接发送到我的电子邮件,但是一旦我单击链接/按钮。它会抛出类似上面的错误。任何的想法 ?
回答by ka_lin
You are not using the required namespace, try to use the following in your controller:
您没有使用所需的命名空间,请尝试在您的控制器中使用以下内容:
use Illuminate\Http\Request;
You are getting the error due to the fact that your script tries to load the Request
class from the current namespace :App\Http\Controllers\Auth
由于您的脚本尝试Request
从当前命名空间加载类,您收到错误消息:App\Http\Controllers\Auth