public function admin_edit($id) { if ($this->data != null) { // save & redirect? if (AppModel::Update(Url::$data['modelName'], $this->data['id'], $this->data)) { $this->Model = AppModel::FindById(Url::$data['modelName'], $this->data['id']); $this->redirect(DS . ADMIN_ROUTE . DS . Url::$data['controller'], false); } } $this->assign('item', $this->Model = AppModel::FindById(Url::$data['modelName'], $id, true)); }
public function destroy($extend = false) { // destroy? if (($success = parent::destroy()) && $extend) { // remove attachments foreach ($this->get_attached as $model) { foreach ($this->{$model} as $attached) { $attached->detach($this); } } // destroy children foreach ($this->get_children as $model) { $soft = in_array($model, $this->soft_destroys); // soft destroy? foreach ($this->{$model} as $child) { if ($soft) { AppModel::Update($model, $child->id, array(strtolower(get_class($this)) . '_id' => null)); } else { $child->destroy(); } } } } return $success; }