public function delete() { // delete all related fields foreach ($this->fields as $field) { $field->delete(); } // delete the module return parent::delete(); }