在 laravel 中一次更新多个列值

update multiple columns value at once in laravel

我正在尝试更新所有选定员工的出勤列 outtime 并已成功存储在数据库中 time.During intime 签到时间,但我遇到了问题更新。我做了类似下面的事情,但它更新了唯一的第一行。应该写什么查询有人帮我吗?

AttendanceController.php

public function checkout(Request $request)
{

    $request->validate([
        'outtime'  => 'required',
        'employee_id' => 'required',
    ]);


    $outTime    = Carbon::parse($request->outtime)->format('H:i:s');
    $date       = date('Y-m-d');
    $employeeIds = $request->employee_id;

    $data = [];


    foreach ($employeeIds as $employeeId) {
        $data[] = [
            'employee_id' => $employeeId,
            'attendance_date' => $date,
        ];

    }

    $update = Attendance::where('employee_id', $data)
                        ->where('attendance_date', $date)
                        ->update([
                            'outtime' => $outTime 
                        ]);


    return back()->with('success', 'Checked Out');       
}

使用这个:

whereIn('employee_id', $employeeIds)