toDateString(); // Get all users $users = Employee::where('restaurant_id', $restaurantId)->get(); foreach ($users as $employee) { // Check if attendance already exists $attendance = Attendance::updateOrCreate( [ 'employee_id' => $employee->id, 'date' => $today, ], [ 'restaurant_id' => $restaurantId, 'first_clock_in' => '09:00:00', // first punch 'last_clock_out' => '18:00:00', // last punch 'hours_worked' => 9, 'status' => 'present', ] ); // Create attendance logs AttendanceLog::updateOrCreate( [ 'attendance_id' => $attendance->id, 'employee_id' => $employee->id, 'type' => 'in', 'punch_time' => $today.' 09:00:00', ], [ 'restaurant_id' => $restaurantId, 'device_id' => 'DEVICE-1', ] ); AttendanceLog::updateOrCreate( [ 'attendance_id' => $attendance->id, 'employee_id' => $employee->id, 'type' => 'out', 'punch_time' => $today.' 18:00:00', ], [ 'restaurant_id' => $restaurantId, 'device_id' => 'DEVICE-1', ] ); } } }