Example #1
0
 /**
  * Get cache model
  *
  * @since 0.0.1
  * @return {object}
  */
 protected function getCacheTarget($type)
 {
     switch ($type) {
         case static::TYPE_CATEGORY:
             $cache_id = $this->category_id;
             $classname = SiteCategory::classname();
             break;
         case static::TYPE_ARTICLE:
             $cache_id = $this->article_id;
             $classname = SiteArticle::classname();
             break;
     }
     if (!$cache_id && $this->getOldAttribute('type') == $type) {
         $cache_id = $this->getOldAttribute('target_id');
     }
     return $classname::findOne(['id' => $cache_id, 'site_id' => $this->site_id]);
 }
Example #2
0
 /**
  * Get its belongs category
  *
  * @since 0.0.1
  * @return {object}
  */
 public function getCategory()
 {
     return $this->hasOne(SiteCategory::classname(), ['id' => 'category_id']);
 }