/** * Run the migrations. * * @return void */ public function up() { Schema::table('studentdropouts', function (Blueprint $table) { // }); $students = Studentterm::getAllStudents(); foreach ($students as $student) { $studentid = $student->studentid; $programid = $this->getFinProgram($studentid); $programYears = Program::select('numyears')->where('programid', $programid)->first()->numyears; $studentsems = $this->countStudentSem($studentid, $programid); if ($studentsems > $programYears * 2) { $newEntry = new Studentdropout(); $newEntry->studentid = $studentid; $newEntry->programid = $programid; $newEntry->collegeid = Program::select('unitid')->where('programid', $programid)->first()->unitid; $newEntry->semesters = $studentsems; $newEntry->save(); } } }