/**
* @return \yii\db\ActiveQuery
*/
public function getParent()
{
return $this->hasOne(Category::className(), ['id' => 'parent_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCategories()
{
return $this->hasMany(Category::className(), ['parent_id' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProducts()
{
return $this->hasMany(Product::className(), ['category_id' => 'id']);
}
public function getChilds($id)
{
$query = Category::find()->where(['parent_id' => $id])->all();
return $query;
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCategory()
{
return $this->hasOne(Category::className(), ['id' => 'category_id']);
}