我想更新 Laravel 中的评论。
<div class="edit-input" id="edit{{$comment->id}}">
<input type="text" name="edit_comment" class="form-control">
<div class="input-group-append">
<a href="{{ route('review-edit', [ 'id' => $comment->id]) }}" class="btn btn-primary">OK</a>
<button class="btn btn-danger" id="editCancel" type="button">Cancel</button>
</div>
</div>
这是我的路线:
Route::get('review-edit/{id}', 'CommentController@editComment')->name('review-edit');
和评论控制器:
public function editComment(Request $request, $id)
{
$updateComment = Comment::findOrFail($id);
$updateComment->user_id = Auth::id();
$updateComment->comment = $request->edit_comment;
$updateComment->save();
return back();
}
当我尝试更新评论时,我收到一条错误消息告诉我
SQLSTATE [23502]:非空违规:7
dd($request->edit_comment) 也给出 null 。我在这里俯瞰什么?
拉莫斯之舞
开满天机