/** * @inheritdoc */ public function getAggregate() { return $this->owner->hasOne(AggregateRating::className(), ['target_id' => $this->owner->primaryKey()[0]])->onCondition(['model_id' => Rating::getModelIdByName($this->owner->className())]); }