/** * View action * @return array|string * @throws HttpException */ public function actionView() { $request = Yii::$app->request; if ($request->get('id') === null) { throw new HttpException(404, Yii::t('kalibao.backend', 'tree_not_found')); } $tree = Tree::findOne($request->get('id')); $json = $tree->treeToJson(); $title = $tree->treeI18ns[0]->label == "" ? Yii::t("kalibao.backend", "tree-home") : $tree->treeI18ns[0]->label; $vars = ['json', 'vars', 'title']; $create = false; if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ['html' => $this->renderAjax('view/_contentBlock.php', compact($vars)), 'scripts' => $this->registerClientSideAjaxScript(), 'title' => $title]; } else { return $this->render('view/view', compact($vars)); } }
/** * @return \yii\db\ActiveQuery */ public function getTree() { return $this->hasOne(Tree::className(), ['id' => 'tree_id']); }
/** * @return \yii\db\ActiveQuery */ public function getTrees() { return $this->hasMany(Tree::className(), ['tree_type_id' => 'id']); }