Reputation: 39
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.
After successful registration, I should be thrown to successfull.blade.php
Please help me.
RegistersUsers.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
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
Upvotes: 1
Views: 1675
Reputation: 1104
Routes:
define
a new function
in HomeController
named as success
and call success.blade.php
inside function.
Route::get('/successfull', 'HomeController@success');
RegisterController
if (Auth::user()->role_id != NULL) {
return redirect('/successfull');
}
RegistersUsers.php
after user account created successfully
redirect('/successfull')->withSuccess(' Account Created Successfully');
Hope it will help you :)
Upvotes: 3