where(['parent_id'=>$parent_id])->orderBy('sort ASC')->with('childs')->all(); } public function getChilds() { return $this->hasMany(self::className(), ['parent_id' => 'id'])->orderBy('sort ASC'); } public function getParent() { return $this->hasOne(self::className(), ['id' => 'parent_id']); } public function getCatFasovka(){ return (!empty($this->fasovka_name)) ? $this->fasovka_name : 'Фасовка'; } public function getCatType(){ return (!empty($this->type_name)) ? $this->type_name : 'Тип'; } public function getCatBrends(){ return (!empty($this->brends_name)) ? $this->brends_name : 'Производители'; } }