繁体   English   中英

Laravel发布带有参数的路线

[英]Laravel post route with parameters

我试图通过我的刀片模板中的表单使用url中的参数来执行发布请求。 这是我的表格:

<form action="/products/{{$produit->id}}" method="post">
     {{ csrf_field() }}
    <input type="text" name="avis_body" />
    <input type="submit" value="Send" />
</form>

这是我的web.php:

Route::post('/products/{$id}', function($id){
    return $id;
});

我不知道我在做什么错。 我收到此错误: 在此处输入图片说明

从路由声明中删除$

Route::post('/products/{id}', function($id){
    return $id;
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM