public function getComments()
 {
     /** @var $this ActiveRecord */
     /** @var $commentsModule Module */
     $commentsModule = \Yii::$app->getModule('comments');
     $itemType = ArrayHelper::getValue($commentsModule->items, $this->className() . '.item_type');
     return $this->hasMany(Comment::className(), ['item_id' => current($this->primaryKey())])->where(['item_type' => $itemType]);
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getChilds()
 {
     return $this->hasMany(Comment::className(), ['parent_id' => 'id']);
 }