/** * @return \yii\db\ActiveQuery */ public function getCategories() { return $this->hasMany(Category::className(), ['id' => 'category_id'])->viaTable('category_has_post', ['post_id' => 'id']); }
public function beforeValidate() { $this->updateTimestamps(); return parent::beforeValidate(); }
/** * @return \yii\db\ActiveQuery */ public function getCategories() { return $this->hasMany(Category::className(), ['parent_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getCategory() { return $this->hasOne(Category::className(), ['id' => 'category_id']); }