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('AnotherController@method');
You can also call another method directly without doing a redirect
return app->call('App\Http\Controllers\AnotherController@method');
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\AnotherController@method’);
needs to be
return app()->call(‘App\Http\Controllers\AnotherController@method’);
Thanks! Updated the post.