/** * Delete the record and all associated data * * @return boolean False if error, True on success */ public function destroy() { $data = $this->toArray(); Event::trigger('user.onUserBeforeDelete', array($data)); // Remove profile fields foreach ($this->profiles()->rows() as $field) { if (!$field->destroy()) { $this->addError($field->getError()); return false; } } // Remove notes foreach ($this->notes()->rows() as $note) { if (!$note->destroy()) { $this->addError($note->getError()); return false; } } // Remove hosts foreach ($this->hosts()->rows() as $host) { if (!$host->destroy()) { $this->addError($host->getError()); return false; } } // Remove tags $this->tag(''); // Attempt to delete the record $result = parent::destroy(); if ($result) { Event::trigger('user.onUserAfterDelete', array($data, true, $this->getError())); } return $result; }