/**
  * Find records
  * @param  array|string                       $parameters
  * @return multitype:\App\Core\Models\Hashtag
  */
 public function find($parameters = null)
 {
     return Category::find($parameters);
 }
 /**
  * Update an existing article
  *
  * @param  number     $id
  * @param  array      $input_data
  * @throws \Exception
  * @return unknown
  */
 public function update($input_data)
 {
     $article = Article::findFirstById($input_data['id']);
     if (!$article) {
         throw new \Exception('Article not found', 404);
     }
     $data = $this->prepareData($input_data);
     $article->setArticleIsPublished($data['article_is_published']);
     $article->setArticleUpdatedAt(new \Phalcon\Db\RawValue('NOW()'));
     foreach ($data['translations'] as $lang => $translation) {
         $article->getTranslations()->filter(function ($t) use($lang, $translation) {
             if ($t->getArticleTranslationLang() == $lang) {
                 $t->assign($translation);
                 $t->update();
             }
         });
     }
     $results = ArticleCategoryArticle::findByArticleId($input_data['id']);
     if ($results) {
         $results->delete();
     }
     if ($data['categories']) {
         $article->categories = Category::find(["id IN (" . $data['categories'] . ")"])->filter(function ($category) {
             return $category;
         });
     }
     $results = ArticleHashtagArticle::findByArticleId($input_data['id']);
     if ($results) {
         $results->delete();
     }
     if ($data['hashtags']) {
         $article->hashtags = Hashtag::find(["id IN (" . $data['hashtags'] . ")"])->filter(function ($hashtag) {
             return $hashtag;
         });
     }
     $user = User::findFirstById((int) $data['article_user_id']);
     if (!$user) {
         throw new \Exception('User not found', 404);
     }
     $article->setArticleUserId($data['article_user_id']);
     return $this->save($article, 'update');
 }