Reputation: 450
When a user has registered his/her new account, redirect to the profile page. I know that to redirect a user to his/her account I would do:
<a href=**"account/Auth::user->username**>{{Auth::user->username}}</a>
And i figured that within Laravel's RegisterController I could do the same with its $redirectTo
property, like so:
protected $redirectTo = Auth::user()->username;
But it does not seem to work, is there a way I could use the User model directly or am I missing the point?
Upvotes: 1
Views: 83
Reputation: 15306
The Laravel auth system also covers that by providing a redirectTo()
method that you can use instead of a $redirectTo
variable.
class RegisterController extends Controller
{
use RegistersUsers;
protected $redirectTo = '/home';
protected function redirectTo()
{
return 'account/'.auth()->user()->username;
}
}
Upvotes: 2