public static function getRoot(PhotoRubrics $model) { $root = $model->roots()->find(); if (!$root) { $model->name = 'Каталог Photo Дерево'; $model->url = 'RootTreePhoto'; $model->parent_id = 0; $model->level = 1; $model->status = 1; $model->saveNode(); $root = $model->roots()->find(); } return $root; }