public function deleteAction($id) { $model = Page::findFirst($id); if ($this->request->isPost()) { $model->delete(); $this->redirect('/page/admin'); } $this->view->model = $model; $this->view->title = 'Удаление страницы'; $this->helper->title('Удаление страницы'); }
/** * Action responsible to display info about single page entity. * * @return \Phalcon\Http\ResponseInterface * @throws \Api\Exception\NotImplementedException */ public function getAction() { //get entity from storage $pageId = (int) $this->request->getQuery('pageId'); $page = \Page\Model\Page::findFirst($pageId); if (!$pageId || !$page) { return $this->render(new \Api\Model\Payload(null, sprintf('Page with id: %s was not found.', $pageId))); } //filter required data for display $filter = new \Api\Filter\Page(); $payload = new \Api\Model\Payload($filter->filter($page)); return $this->render($payload); }
public function deleteAction($id) { $model = Page::findFirst($id); if ($model->getSlug() == 'index') { $this->flash->error($this->helper->at('Index page can not be removed')); return $this->redirect($this->url->get() . 'page/admin'); } if ($this->request->isPost()) { $model->delete(); $this->redirect($this->url->get() . 'page/admin'); } $this->view->model = $model; $this->helper->title($this->helper->at('Delete Page'), true); }