【问题标题】:Laravel post route with parameters带参数的 Laravel 发布路由
【发布时间】:2018-06-11 13:41:54
【问题描述】:

我试图通过我的刀片模板中的表单和 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;
});

我不知道我做错了什么。我收到此错误:

【问题讨论】:

  • 错字{{$produit-&gt;id}} ?检查是否为null
  • 不,它不为空

标签: php laravel parameters routes


【解决方案1】:

从路由声明中删除$

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

【讨论】:

    猜你喜欢
    • 2015-10-30
    • 2017-07-10
    • 2017-04-04
    • 2017-10-21
    • 2014-05-29
    • 2018-08-31
    • 2015-04-17
    • 2016-01-20
    • 1970-01-01
    相关资源
    最近更新 更多