public function viewAction()
 {
     $fc = FrontController::getInstance();
     $model = new FrontModel();
     $articleModel = new ArticleTableModel();
     $userModel = new UserTableModel();
     $id = filter_var($fc->getParams()['id'], FILTER_SANITIZE_NUMBER_INT);
     if (!$id) {
         header('Location: /admin/notFound');
         exit;
     }
     $articleModel->setId($id);
     $articleModel->setTable('article');
     $article = $articleModel->readRecordsById();
     $userModel->setId($article[0]['author']);
     $userModel->setTable('user');
     $model->setData(['article' => $article, 'author' => $userModel->readRecordsById('id', 'id, username')]);
     $output = $model->render('../views/blog/view.php', 'withoutSlider');
     $fc->setPage($output);
 }
 public function editArticleAction()
 {
     $fc = FrontController::getInstance();
     $model = new AdminModel('Редактирование статьи');
     $articleModel = new ArticleTableModel();
     $userModel = new UserTableModel();
     $id = filter_var($fc->getParams()['id'], FILTER_SANITIZE_NUMBER_INT);
     $articleModel->setId($id);
     $articleModel->setTable('article');
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $articleModel->setData();
         $articleModel->updateRecord();
         Session::setMsg('Статья успешно обновлена', 'success');
         header('Location: /admin/viewArticle/id/' . $articleModel->getArticle()->getData()['id']);
         exit;
     } else {
         $article = $articleModel->readRecordsById();
         $userModel->setId($article[0]['author']);
         $userModel->setTable('user');
         $model->setData(['article' => $article, 'author' => $userModel->readRecordsById('id', 'id, username')]);
         $output = $model->render('../views/admin/blog/editArticle.php', 'admin');
         $fc->setPage($output);
     }
 }