count(); $updatedProjects = []; Log::info($totalProjects); foreach ($projects as $index => $project) { $project->scurve = MasterFunctionsHelper::getSCurve($project->id); if ($project->scurve && $project->scurve[0]) { $planningArray = $project->scurve[0]['data']['percentagePlan']; $actualArray = $project->scurve[0]['data']['percentageReal']; $planningProgress = !empty($planningArray) ? end($planningArray) : 0; $actualProgress = !empty($actualArray) ? end($actualArray) : 0; $selisihProgress = $planningProgress - $actualProgress; $scheduleHealth = ($selisihProgress > 0 && $selisihProgress <= 20) ? 'warning' : (($selisihProgress == 0) ? 'on-schedule' : 'behind-schedule'); Log::info("Updating project with ID: " . $project->id . " - Schedule Health: " . $scheduleHealth); $project->update(['schedule_health' => $scheduleHealth]); $updatedProjects[] = $project->id; } } if ($totalProjects > 0) { echo "\n------------------------------------------\n"; echo "All projects have been updated."; } } }