如何从laravel 5.6注销

时间:2019-01-02 12:01:43

标签: laravel laravel-5.6

我要在注册后注销。我怎么做?

这是我的注册控制器:

protected function create(array $data)
{

    $user =  User::create([
      'firstname' => $data['firstname'],
        'secondname' => $data['secondname'],
        'email' => $data['email'],
        'password' => Hash::make($data['password']),
        'address' => $data['address'],
        'mobileno' => $data['mobileno'],
        'type' => $data['type'],
    ]);

    $verifyUser = VerifyUser::create([
        'user_id' => $user->id,
        'token' => str_random(40)
    ]);

    Mail::to($user->email)->send(new VerifyMail($user));

    return $user;

    return redirect('/login')->with('status', 'We sent you an activation code. Check your email and click on the link to verify.');
}

2 个答案:

答案 0 :(得分:0)

在控制器中添加这两行并检查

public function __construct()
{
    $this->middleware('auth');
}

答案 1 :(得分:0)

您可以更改网址:-

protected $redirectTo = '/where/you/want/to/redirect';

app/Http/Controller/Auth/RegisterController.php注册后

并注销:-

public function __construct()
{
    $this->middleware('guest')->except('logout');
}