function delete() { if (!empty($this->id)) { //clean make the delete cascade into association records $filter = new field_filter('classid', $this->id); instructor::delete_records($filter, $this->_db); student::delete_records($filter, $this->_db); trackassignment::delete_records($filter, $this->_db); classmoodlecourse::delete_records($filter, $this->_db); student_grade::delete_records($filter, $this->_db); waitlist::delete_records($filter, $this->_db); parent::delete(); $context = \local_elisprogram\context\pmclass::instance($this->id); $context->delete(); } }