How to redirect to previous page after successful register in laravel?

How to redirect to previous page after successful register in laravel?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by orpha , 2 hours ago

@giovanny.lueilwitz 

To redirect to the previous page after successful registration in Laravel, you can use the redirect()->back() method in your controller. Here's an example:

1
2
3
4
5
6
7
public function register(Request $request)
{
    // Your registration logic here

    // Redirect back to the previous page
    return redirect()->back();
}


Alternatively, you can also specify a specific route to redirect to after successful registration:

1
2
3
4
5
6
7
public function register(Request $request)
{
    // Your registration logic here

    // Redirect to a specific route
    return redirect()->route('dashboard');
}


Replace 'dashboard' with the route name you want to redirect to.