public function getBatchDelayedRate() { $batchDelayedRate = []; //To get batches of program whithin 2000-2009 $progYears = Studentterm::where('programid', $this->programid)->groupBy('year')->orderBy('year', 'asc')->lists('year'); if ($this->revisionyear > 2009) { $max = 2012; } else { if ($this->programid == 28) { $max = 2013 - 4; } else { $max = 2013 - $this->numyears; } } $batches = []; foreach ($progYears as $progYear) { if ($progYear > 1999 && $progYear < $max + 1) { array_push($batches, $progYear * 100000); } } foreach ($batches as $batch) { $batchEnd = $batch + 100000; $allBatchStudents = count(Studentterm::select('studentid')->where('studentid', '>', $batch)->where('studentid', '<', $batchEnd)->where('programid', $this->programid)->groupBy('studentid')->get()); $allBatchDelayed = Studentdelayed::getBatchDelayedCountProgram($batch, $this->programid); $batchDelayedRate[$batch / 100000] = round($allBatchDelayed / $allBatchStudents * 100, 2); } return $batchDelayedRate; }