我正在使用Laravel 5.3 My 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代码:
<?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);
}
}
我的管理路线:
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代码:
<?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;
}
我可以将链接发送到我的电子邮箱,但是一旦我点击链接/按钮。 它会抛出上面的错误。有什么想法吗?
答案 0 :(得分:43)
您没有使用所需的命名空间,请尝试在控制器中使用以下命令:
use Illuminate\Http\Request;
由于您的脚本尝试从当前命名空间加载Request
类,您收到错误:App\Http\Controllers\Auth
答案 1 :(得分:-1)
缺少Request类的路径 请使用此路径: 使用 Illuminate\Http\Request;