Home > Back-end >  issue with laravel returning to a route after completing function in controller class
issue with laravel returning to a route after completing function in controller class

Time:11-09

I am trying to get a Laravel controller to return to a route after a create function is complete.

I have tried the following code in the screenshots, PLEASE HELP!!!

laravel error screenshot

mycode file screenshot

CodePudding user response:

return redirect()->route('Communities.Index')

CodePudding user response:

For redirection: return redirect()->route('Communities.Index');

For redirection to previous route: return redirect()->back();

For redirection with payload:

return redirect()->route('Communities.Index')->with('success', 'Item added to cart successfully!');

return redirect()->back()->with('error', 'This is an error message.');

  • Related