Пример #1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategories()
 {
     return $this->hasMany(Category::className(), ['id' => 'category_id'])->viaTable('category_has_post', ['post_id' => 'id']);
 }
Пример #2
0
 public function beforeValidate()
 {
     $this->updateTimestamps();
     return parent::beforeValidate();
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategories()
 {
     return $this->hasMany(Category::className(), ['parent_id' => 'id']);
 }
Пример #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategory()
 {
     return $this->hasOne(Category::className(), ['id' => 'category_id']);
 }