Laravel 4 - Redirect ::带参数的路由

时间:2023-01-20 11:11:48

Is it possible to specify a Redirect::route to a Resource Controller with parameters and specify how the parameters are handled?

是否可以使用参数指定到资源控制器的Redirect :: route并指定如何处理参数?

I have the following route defined:

我定义了以下路线:

Route::resource('account','AccountController');

In another route I want to be able to pass parameters to account.create with values acquired earlier so I can pre-populate the create form, but want them passed using as a POST request.

在另一个路由中,我希望能够使用先前获取的值将参数传递给account.create,以便我可以预先填充创建表单,但希望它们作为POST请求传递。

Redirect::route('account.create',array('name' => $name));

Redirect :: route('account.create',array('name'=> $ name));

The above works, but passes the parameters as a GET request.

上述工作,但作为GET请求传递参数。

2 个解决方案

#1


27  

Redirect::route('account.create')->with('name', $name);

This'll flash it to the session, which you would then retrieve after the redirect with Session::get('name').

这会将它闪存到会话中,然后在使用Session :: get('name')重定向后再检索该会话。

#2


0  

Another extra info

另一个额外信息

You can't (o should not?) use dots in config session cookie's var. I had thoubles with this before. If you are having issues with this go check this value.

你不能(不应该?)在配置会话cookie的var中使用点。我之前有过这个问题。如果您遇到此问题,请检查此值。

Refer to this link for more information.

有关更多信息,请参阅此链接。

#1


27  

Redirect::route('account.create')->with('name', $name);

This'll flash it to the session, which you would then retrieve after the redirect with Session::get('name').

这会将它闪存到会话中,然后在使用Session :: get('name')重定向后再检索该会话。

#2


0  

Another extra info

另一个额外信息

You can't (o should not?) use dots in config session cookie's var. I had thoubles with this before. If you are having issues with this go check this value.

你不能(不应该?)在配置会话cookie的var中使用点。我之前有过这个问题。如果您遇到此问题,请检查此值。

Refer to this link for more information.

有关更多信息,请参阅此链接。