Posts Learn Components Snippets Categories Tags Tools About
/

Redirect to Specific Controller Method in Laravel

Learn how to redirect to a specific controller method in Laravel as an alternative to route naming

Created on Aug 17, 2021

218 views

One of the ways to redirect to a resource/method of a controller is to use the "redirect()" method and chain it with the "action()" method. The action method accepts the controller@method as the 1st parameter and any of the necessary data as the 2nd parameter.
return redirect()->action('PostController@show', ['slug' => $slug]);
By writing it this way, you will be able to directly get the URL to the resource/method by only remembering the controller and method name.

Similar Post

  • Redirect to Named Route in Laravel

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

)