コード例 #1
0
ファイル: Article.php プロジェクト: Ethennoob/yii2-blog
 /**
  * Relations
  */
 public function getCategory()
 {
     return $this->hasOne(Category::className(), ['id' => 'cid'])->where(['status' => Category::STATUS_ACTIVE]);
 }
コード例 #2
0
ファイル: Category.php プロジェクト: Ethennoob/yii2-blog
 /**
  * Relations
  */
 public function getParent()
 {
     return $this->hasOne(Category::className(), ['id' => 'pid'])->where(['status' => self::STATUS_ACTIVE]);
 }