[英]Create redirect after registration Laravel
I want after successful registration I was redirected to successfull.blade.php
, but for some reason it either gives a 404 error, that the page was not found, or that it always throws me to home ... I can't handle it please help me.我想在成功注册后我被重定向到
successfull.blade.php
,但由于某种原因,它要么给出 404 错误,要么找不到页面,要么总是把我扔回家......我无法处理它请帮我。 After successful registration, I should be thrown to successfull.blade.php
Please help me.注册成功后,我应该被抛出到
successfull.blade.php
请帮帮我。
RegistersUsers.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');
}
RegisterController
注册控制器
protected function redirectPath()
{
if (Auth::user()->role_id==NULL) {
return '/successfull';
} else {
return '/successfull';
}
}
web.php
网页.php
Auth::routes();
Route::get('/home', 'HomeController@getUser')->name('users');
Route::get('/successfull', 'Auth\RegisterController@redirectPath');
homecontroller
家庭控制器
public function getUser(){
$user=auth()->user();
return view('home',[
'users' => $user,
]);
}
throws me to home
because of homecontroller
, but I want it to be only after login, and after registration I need to be redirected to another file由于
homecontroller
将我扔home
,但我希望它仅在登录后才能使用,并且在注册后我需要重定向到另一个文件
Routes: define
a new function
in HomeController
named as success
and call success.blade.php
inside function.路由:在
HomeController
define
一个名为success
的新function
,并在函数内部调用success.blade.php
。
Route::get('/successfull', 'HomeController@success');
RegisterController注册控制器
if (Auth::user()->role_id != NULL) {
return redirect('/successfull');
}
RegistersUsers.php注册用户.php
after user account created successfully用户账户创建成功后
redirect('/successfull')->withSuccess(' Account Created Successfully');
Hope it will help you :)希望它会帮助你:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.