我想将$comment->id发送到ControllerupdateComment方法,只需更新一列(注释(
这是我的代码,它带来了这样的错误:BoardController.php第153行中的ErrorException:App''Http''Controllers''BoardController::updateComment((缺少参数1
查看
<form method="post" action="{{route('comment.update', $comment->id)}}">
<input type="hidden" name="_method" value="put">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<textarea name="comment">'+beforeComment+'</textarea>
<input type="submit" value="등록">
</form>
控制器
public function updateComment($id) {
$comment = comment::findOrFail($id);
$body = Request::input('comment');
$comment->update(['comment' => $body]);
return redirect()->back();
}
路线
Route::match(['put', 'patch'], 'comment', ['as'=>'comment.update', 'uses'=>'BoardController@updateComment']);
您需要在您的路线中定义它,如下所示:
Route::match(['put', 'patch'], 'comment/{id}', ['as'=>'comment.update', 'uses'=>'BoardController@updateComment']);
通过在其中添加{id}
。