简而言之:是的
您当然可以使用
Redirect::back()->withMessage('Profile saved!')
代替
Redirect::to('profile')->withMessage('Profile saved!')
*Laravel中的漂亮功能,它在->with('name', 'value')
上解析你的骆驼大小写,这样->withName('value')
的工作方式是一样的。
也。。。。
我假设您的表单绑定到模型,例如预填充表单字段,但如果没有,您可能希望在重定向上重新刷新输入(或者如果您的验证失败并且您希望用户能够更正无效信息)。Form::model($user, [...]
只是一个片段[未经测试]...
// [[... validation and other magic here]]
if ($validator->fails()) {
return Redirect::back()
->withMessage($message_fail)
->withErrors($validator)
->withInput();
}
return Redirect::back()
->withMessage($message_success)
希望有所帮助!
推特: @ErikOnTheWeb