Error return Redirect route regions - with message State saved correctly

0 votes

I'm developing a Laravel 5 app, I have this route

Route::get('states/{id}/regions', ['as' => 'regions', 'uses' => 'RegionController@index']);

In my controller, after I make a post call correctly, I want to redirect to that view, with this command:

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

The problem is that I don't know how can I pass {id} parameter, which should be in my URL.

Dec 1, 2020 in Laravel by kartik
• 37,510 points
854 views

1 answer to this question.

0 votes

Hello @kartik,

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!!!');
answered Dec 1, 2020 by Niroj
• 82,880 points

Related Questions In Laravel

0 votes
2 answers

How to solve expected response code 220 but got code “”, with message “” in Laravel?

This problem can generally occur when you ...READ MORE

answered Dec 16, 2020 in Laravel by Gitika
• 65,910 points
40,921 views
0 votes
1 answer

How can I get the error message for the mail() function?

Hello @kartik, You can use error_get_last() when mai l()returns false. $success = mail('example@example.com', ...READ MORE

answered Jul 30, 2020 in Laravel by Niroj
• 82,880 points
8,716 views
0 votes
1 answer

Error:Loading composer repositories with package information Updating dependencies (including require-dev) Killed

Hello @kartik, The "Killed" message usually means your ...READ MORE

answered Aug 4, 2020 in Laravel by Niroj
• 82,880 points
7,549 views
0 votes
1 answer

How to give custom field name in laravel form validation error message?

Hello @kartik, You can specify custom error message ...READ MORE

answered Sep 30, 2020 in Laravel by Niroj
• 82,880 points
4,422 views
0 votes
1 answer

jQuery AJAX fires error callback on window unload - how do I filter out unload and only catch real errors?

Hello, In the error callback or $.ajax you have three ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
3,719 views
0 votes
1 answer

How do I pass command line arguments to a Node.js program?

Hello @kartik, If your script is called myScript.js ...READ MORE

answered May 5, 2020 in Java-Script by Niroj
• 82,880 points
2,928 views
0 votes
1 answer

Error:Issue when trying to use IN() in wordpress database

Hello @kartik, Try this code : // Create an ...READ MORE

answered May 8, 2020 in PHP by Niroj
• 82,880 points
836 views
+2 votes
1 answer

How do I debug Node.js applications?

Hello @kartik, Use node-inspector  from any browser supporting WebSocket. Breakpoints, ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,880 points
775 views
0 votes
1 answer

Error:Swift_TransportException Expected response code 220 but got code "", with message ""

Hello @kartik, This problem can generally occur when ...READ MORE

answered Jul 30, 2020 in Laravel by Niroj
• 82,880 points
3,913 views
0 votes
1 answer

Error: 'Unchecked runtime.lastError: The message port closed before a response was received' chrome issue?

Hii, I had same problem when responding on ...READ MORE

answered Mar 30, 2020 in Laravel by Niroj
• 82,880 points
52,556 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP