/** * Добавим ссылку на нашего специфического владельца * @return \yii\db\ActiveQuery */ public function getMaterial() { return $this->hasOne(Post::className(), ['id' => 'material_id']); }
/** * @return \yii\db\ActiveQuery */ public function getPost() { return $this->hasOne(Post::className(), ['id' => 'post_id']); }
/** * Возвращает посты по тегу * @return \yii\db\ActiveQuery */ public function getPostsTag($offset = false, $limit = false) { return $this->hasMany(Post::className(), ['id' => 'post_id'])->viaTable('{{%blog_tag_post}}', ['tag_id' => 'id'])->where(['publish_status' => [Post::STATUS_PUBLISH, Post::STATUS_ARCHIVE]])->orderBy(['id' => SORT_DESC])->offset($offset)->limit($limit); }