Redirect::route with parameter in URL in Laravel

23 0 0 0

Last Updated : 2020-10-24 12:11:53

redirect to specific route with parameters in URl in laravel

You can pass the route parameters as second argument to route():


return \Redirect::route('regions', [$id])->with('message', 'State saved correctly!!!');

If it's only one you also don't need to write it as array:


return \Redirect::route('regions', $id)->with('message', 'State saved correctly!!!');

In case your route has more parameters, or if it has only one, but you want to clearly specify which parameter has each value (for readability purposes), you can always do this:


return \Redirect::route('regions', ['id'=>$id,'OTHER_PARAM'=>'XXX',...])->with('message', 'State saved correctly!!!');

Mahmoud Anwar

Mahmoud Anwar

Back End Developer with a passion for developing innovative web applications that expedite the efficiency and effectiveness of organizational success. Well-versed in technology and writing code to create systems that are reliable and user-friendly. Also has the proven ability to motivate, educate, and collaborate effectively to build web applications and effectively track changes. Confident communicator, strategic thinker, and innovative creator to develop software that is customized to meet a company’s organizational needs, highlight their core competencies, and further their success.