Пример #1
0
 public function action_add()
 {
     $lData = Input::post('article', null);
     if (empty($lData)) {
         die(json_encode(['status' => 'error', 'message' => 'Empty article data'], JSON_UNESCAPED_UNICODE));
     }
     $lData['user_id'] = $this->current_user['id'];
     Model_Articles::add($lData);
     die(json_encode(['status' => 'ok'], JSON_UNESCAPED_UNICODE));
 }
Пример #2
0
 public function post_index($title, $id_category)
 {
     $newArticle = new Model_Articles(['title' => $title, 'category' => Model_Categories::getById($id_category), 'author' => $this->_currentUser]);
     $newArticle = Model_Articles::add($newArticle);
     $this->response->redirect('articles/edit?id=' . $newArticle->getId(), 201);
 }