public function seedHighGrades($batches, $allStudents, $programid) { foreach ($batches as $batch) { $students = $allStudents[$batch]; $totalHigh = 0; foreach ($students as $student) { $gwa = Studentterm::getOneGradesProgram($student->studentid, $programid); if ($gwa > 1.0 || $gwa < 3.0) { $totalHigh++; } } $newCorrelation = new Correlation(); $newCorrelation->factorid = 7; $newCorrelation->batch = $batch; $countStudents = count($students); if ($countStudents > 0) { $newCorrelation->ratio = $totalHigh / $countStudents; } else { $newCorrelation->ratio = 0; } $newCorrelation->unittype = 'program'; $newCorrelation->programid = $programid; $newCorrelation->save(); } }