skip to Main Content

SQLSTATE[23000]: Integrity constraint violation: 1048 Column
’employee_id’ cannot be null (Connection: mysql, SQL: update
attendance_employees set employee_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 where id = 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


  1. Check if 'employee_id' is present in the request before trying to update the record.

    if (!$request->has('employee_id')) {
        return redirect()->back()->with('error', __('Employee ID is required.'));
    }
    
    $attendanceEmployee = AttendanceEmployee::find($id);
    // rest of your code
    
    Login or Signup to reply.
  2. In your DataTable, the "employee_id" column should not be null. Therefore, when inserting or updating a record, it is imperative to provide a non-null value for the "employee_id" field.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search