Laravel 4-带有参数的Redirect :: route [英] Laravel 4 - Redirect::route with parameters
问题描述
是否可以使用参数指定到资源控制器的Redirect :: route并指定如何处理参数?
Is it possible to specify a Redirect::route to a Resource Controller with parameters and specify how the parameters are handled?
我定义了以下路线:
Route::resource('account','AccountController');
在另一种方法中,我希望能够使用较早获取的值将参数传递到account.create,以便我可以预先填充创建表单,但希望将它们用作POST请求传递.
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.
Redirect::route('account.create',array('name' => $name));
上面的方法有效,但是将参数作为GET请求传递.
The above works, but passes the parameters as a GET request.
推荐答案
Redirect::route('account.create')->with('name', $name);
这会将其刷新到会话中,然后您可以在通过Session::get('name')
重定向后检索该会话.
This'll flash it to the session, which you would then retrieve after the redirect with Session::get('name')
.
这篇关于Laravel 4-带有参数的Redirect :: route的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!