@dedrick
To do a simple redirect in Laravel, you can use the redirect() function, which is a helper function provided by Laravel.
Here is an example of how to do a simple redirect:
1 2 3 4 |
public function redirectToPage()
{
return redirect('/newpage');
}
|
1
|
Route::get('/newpage', 'NewPageController@index')->name('newpage');
|
Then, in your controller method, you can use the route() function to redirect to the named route:
1 2 3 4 |
public function redirectToPage()
{
return redirect()->route('newpage');
}
|
1 2 3 4 |
public function redirectToPreviousPage()
{
return redirect()->back();
}
|
These are some simple examples of how to do a redirect in Laravel. You can customize the redirects further by adding other options, such as redirecting with data or specifying a status code.