在工作恢復密碼,一切工作正常,因爲我加了驗證,但我得到一個錯誤:「未定義的方法... \密碼\ PasswordController ::驗證」未定義的方法::驗證在laravel
im調用函數是postEmail
我在做什麼錯?
我的代碼:
<?php
namespace Illuminate\Foundation\Auth;
use Illuminate\Http\Request;
use Illuminate\Mail\Message;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Password;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
trait ResetsPasswords
{
use RedirectsUsers;
/**
* Send a reset link to the given user.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
$response = Password::sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
switch ($response) {
case Password::RESET_LINK_SENT:
return redirect()
->back()
->with('status', trans($response));
case Password::INVALID_USER:
return redirect()
->back()
->withErrors(['email' => trans($response)]);
}
}
}
將您的片段是有點在搞砸頂部,所以我不能看到;該控制器是否擴展了基本控制器「App \ Http \ Controllers \ Controller」?應該有一個'ValidatesRequests'特性。 –