【发布时间】:2017-02-19 16:41:40
【问题描述】:
我想将 $comment->id 发送到控制器的 updateComment 方法, 只需更新一列(评论)
这是我的代码,它在 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']);
【问题讨论】: