Код: Выделить всё
public function getProducts()
{
return $this->hasMany(Product::className(), ['catalog_id' => 'id'])->orderBy('position');
}
Код: Выделить всё
public function getRoots()
{
return self::find()->where(['parent_id'=>null])->orderBy('position');
}