command->error("JSON file not found at $jsonPath"); return; } $roster = json_decode(File::get($jsonPath), true); $total = count($roster); $count = 0; $this->command->getOutput()->progressStart($total); foreach ($roster as $item) { $employee = Employee::where('employee_id', $item['code'])->first(); if ($employee) { $shift = null; if ($item['shift_name']) { $shift = Shift::where('name', $item['shift_name'])->first(); } // Create or update the attendance record (Roster) AttendanceRecord::updateOrCreate( [ 'employee_id' => $employee->user_id, // Attendance uses user_id as employee_id relationship 'date' => $item['date'] ], [ 'shift_id' => $shift ? $shift->id : null, 'is_rest_day' => $item['is_rest_day'], 'status' => 'absent', // Roster placeholder 'created_by' => 1 ] ); } $this->command->getOutput()->progressAdvance(); $count++; } $this->command->getOutput()->progressFinish(); $this->command->info("Synced $count roster records successfully."); } }