如何在Input::all()之后附加额外的值


How to attach extra values after Input::all() in Laravel

http://localhost/posts/post_id页有一个评论表单
当我提交表单时,我想将post_id值附加到Input::all(),因为表单不包括post_id的输入字段。post_id在评论表中的列名是post_id,创建评论的路由是comments.store
任何想法?谢谢!

我认为这应该可以工作:Input::merge(array('post_id' => $post_id));

这个怎么样?

function store($post_id)
{
    $data = Input::all();
    $comment = new Comment($data);
    $comment->post_id = $post_id;
    $comment->save();
}

就用这个:

Request::instance()->query->set('key','value');