这个问题是关于如何更新类型为main且sub type列具有相同值的1 db列, 例如,这是在db表中的样子:
ID : 1 type : main stream_twitch: 0
ID : 2 type : sub stream_twitch: 0
ID : 3 type : sub stream_twitch: 0
现在,如果我在其主目录上编辑stream_twitch的文本字段,它还将编辑另一列
<input type ="text" name='stream_twitch' id="stream_twitch" class='form-control' value="{{$match->stream_twitch}}" style="text-align: center;"/>
这是控制器的代码
public function editStream(Request $request) {
$validator = \Validator::make($request->all(), [
'match_id' => 'required',
'schedule' => 'sometimes|nullable|date'
]);
if ($validator->passes()) {
$match = \App\Match::find($request->match_id);
if ($match->status == 'open') {
if ($match->status == 'ongoing')
setupOngoingMatch($match);
return ['success' => 'done1'];
}
if($match->status =='ongoing'){
$match->stream_twitch = $request->stream_twitch;
$match->stream_yt = $request->stream_yt;
$match->stream_fb = $request->stream_fb;
$match->save();
return ['success' => 'done1'];
}
} else
return ['error' => $validator->errors(), 'data' => $request->all()];
}