public function restore($id = null)
{
if (!$this->hasField('enabled')) {
return $this;
}
if (!empty($id)) {
$this->findOrFail($id);
}
$id = $this->getId();
if (!$id) {
throw new RecordNotLoaded("Can't change the state of a not loaded DataModel");
}
$this->triggerEvent('onBeforeRestore', array(&$id));
$enabled = $this->getFieldAlias('enabled');
$this->{$enabled} = 0;
$this->save();
$this->triggerEvent('onAfterRestore', array(&$id));
return $this;
}