注册拉拉维尔后创建重定向



我想在成功注册后我被重定向到successfull.blade.php,但由于某种原因,它要么给出 404 错误,找不到页面,要么它总是把我扔到家......我无法处理它,请帮助我。 注册成功后,我应该被扔到successfull.blade.php请帮助我。

注册用户.php

public function register(Request $request)
{
$this->validator($request->all())->validate();
event(new Registered($user = $this->create($request->all())));
$this->guard()->login($user);
return $this->registered($request, $user)
?: redirect()->to('/successfull');
}

寄存器控制器

protected function redirectPath()
{
if (Auth::user()->role_id==NULL) {
return '/successfull';
} else {
return '/successfull';
}
}

网络.php

Auth::routes();
Route::get('/home', 'HomeController@getUser')->name('users');
Route::get('/successfull', 'AuthRegisterController@redirectPath');

主控制器

public function getUser(){
$user=auth()->user();
return view('home',[
'users' =>  $user,
]);
}

因为homecontroller把我扔到home,但我希望它只在登录后,注册后我需要重定向到另一个文件

路由:defineHomeController中名为success的新function,并在函数内调用success.blade.php

Route::get('/successfull', 'HomeController@success');

寄存器控制器

if (Auth::user()->role_id != NULL) {
return redirect('/successfull');
}

注册用户.php

成功创建用户帐户后

redirect('/successfull')->withSuccess(' Account Created Successfully');

希望它能帮助你:)

最新更新