SQLSTATE[23000]: Integrity constraint violation: 1048 Column
’employee_id’ cannot be null (Connection: mysql, SQL: update
attendance_employees
setemployee_id
= ?,date
= ?,clock_in
=
?,clock_out
= ?,late
= -473049:00:00,early_leaving
=
473058:00:00,attendance_employees
.updated_at
= 2023-12-19
16:23:08 whereid
= 2)
issue when i clock in its workk but when I clock out have isue
`else
{
$overtime = '00:00:00';
}
$attendanceEmployee = AttendanceEmployee::find($id);
$attendanceEmployee->employee_id = $request->employee_id;
$attendanceEmployee->date = $request->date;
$attendanceEmployee->clock_in = $request->clock_in;
$attendanceEmployee->clock_out = $request->clock_out;
$attendanceEmployee->late = $late;
$attendanceEmployee->early_leaving = $earlyLeaving;
$attendanceEmployee->overtime = $overtime;
$attendanceEmployee->total_rest = '00:00:00';
$attendanceEmployee->save();
return redirect()->back()->with('success', __('Employee attendance successfully updated.'));
}
}
else
{
return redirect()->back()->with('error', __('Employee are not allow multiple time clock in & clock for every day.'));
}
}`
** $attendanceEmployee->save();**
The main issue is comming from clock in side error IN ** $attendanceEmployee->save();
**
when user clock out it show this error
2
Answers
Check if
'employee_id'
is present in the request before trying to update the record.In your DataTable, the "
employee_id
" column should not be null. Therefore, when inserting or updating a record, it is imperative to provide anon-null
value for the "employee_id
" field.