If you have ever need to forward or call another controller from a controller in Laravel, here are two methods
This will redirect the request to another controller’s method.
return redirect()->action('[email protected]');
You can also call another method directly without doing a redirect
return app->call('App\Http\Controllers\[email protected]');
Hope one of these methods help!
Thanks for reading. Make sure you follow me on Twitter to stay up to date on the progress of my side projects T.LY, Weather Extension, and Link Shortener Extension. If you are interested in the tech I use daily, check out my uses page.
Hello,
The second solution is wrong:
return app->call(‘App\Http\Controllers\[email protected]’);
needs to be
return app()->call(‘App\Http\Controllers\[email protected]’);
Thanks! Updated the post.