Laravel where 和 where not 工作不正常
Laravel where and where not aren't working properly
projectmember table 有列名状态。我想要的是如果 $req 值没有打开,则将状态更新为 6
projectmember.member_id 归档
以下代码将指定的所有状态更新为 40 project_id
$req = [1,2,3];
foreach ($req as $key => $item) {
$updated = Projectmember::where('member_id','!=', $item )
-> where('project_id','=', $id )
->update([
'status' => 40,
]);
}
您可以使用 WhereNotIn
在数组中检查您的 ID
试试这个
status
更新为6
$req = [1, 2, 3, 4];
$updated = Projectmember::whereNotIn('id', $req)->where('project_id', $id)->update([
'status' => 6,
]);
projectmember table 有列名状态。我想要的是如果 $req 值没有打开,则将状态更新为 6 projectmember.member_id 归档
以下代码将指定的所有状态更新为 40 project_id
$req = [1,2,3];
foreach ($req as $key => $item) {
$updated = Projectmember::where('member_id','!=', $item )
-> where('project_id','=', $id )
->update([
'status' => 40,
]);
}
您可以使用 WhereNotIn
在数组中检查您的 ID
试试这个
status
更新为6
$req = [1, 2, 3, 4];
$updated = Projectmember::whereNotIn('id', $req)->where('project_id', $id)->update([
'status' => 6,
]);