Home / Snippets / Redirect to Specific Controller Method in Laravel
Redirect to Specific Controller Method in Laravel cover

Redirect to Specific Controller Method in Laravel

227

2 years ago

0 comments

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
notion avatar

Ahabz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

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

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this