/** * Get the entity related to user in the active identity * * @return \Models\Users */ public function getUser() { $identity = $this->session->get('auth'); if (isset($identity['id'])) { $user = Users::findFirstById($identity['id']); if ($user == false) { throw new Exception('Такого пользователя не существует'); } return $user; } return false; }
/** * Deletes a User * * @param int $id */ public function deleteAction($id) { $model = Users::findFirstById($id); if (!$model) { $this->flash->error("Пользователь не найден"); return $this->dispatcher->forward(array('action' => 'index')); } if (!$model->delete()) { $this->flash->error($model->getMessages()); } else { $this->flash->success("Пользователь удален"); } return $this->dispatcher->forward(array('action' => 'index')); }