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

by giovanny.lueilwitz , in category: Third Party Scripts , 7 months ago

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

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by orpha , 7 months 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.

Related Threads:

How to get data from previous page in laravel?
How to store previous page url as string in vue.js?
How to register middleware in kernel in laravel?
How to change login & register view in laravel?
How to check and control previous url in laravel?
How to redirect page in codeigniter?