public function trash($id = null) { if (!empty($id)) { $this->findOrFail($id); } $id = $this->getId(); if (!$id) { throw new RecordNotLoaded("Can't trash a not loaded DataModel"); } if (!$this->hasField('enabled')) { throw new SpecialColumnMissing("DataModel::trash method needs an 'enabled' field"); } $this->triggerEvent('onBeforeTrash', array(&$id)); $enabled = $this->getFieldAlias('enabled'); $this->{$enabled} = -2; $this->save(); $this->triggerEvent('onAfterTrash', array(&$id)); return $this; }