laravel 5.6参数1传递给App \ Http \ Controllers \ Auth \ RegisterController :: registered()

时间:2018-07-24 11:39:29

标签: laravel laravel-5.2

我正在尝试发送验证电子邮件,这是给我错误的代码

protected function registered(Request $request, $user)
{
    $this->guard()->logout();
    return redirect('/login')->with('status', 'We sent you an activation code. 
            Check your email and click on the link to verify.');
}

它给我以下错误:

  

传递给App \ Http \ Controllers \ Auth \ RegisterController :: registered()的参数1必须是App \ Http \ Controllers \ Auth \ Request的实例,Illuminate \ Http \ Request的实例已在/ home /中调用bassel / book_donation / vendor / laravel / framework / src / Illuminate / Foundation / Auth / RegistersUsers.php,第37行

为了解决这个问题,我在RegisterController中添加了以下内容:

use App\Http\Controllers\Auth\Request;

但是那并不能解决问题,我该如何解决?

1 个答案:

答案 0 :(得分:2)

use Illuminate\Http\Request;

class .... 
{
    ...
    protected function registered(Request $request, $user)
    {
        $this-s>guard()->logout();
        return redirect('/login')->with('status', 'We sent you an activation code. 
                Check your email and click on the link to verify.');
    }
}

Request $request现在说必须传递Illuminate\Http\Request类,因为它将是要传递给此方法的实例。