public function up() { $model = Config::findOne(Robots::KEY_ROBOTS); if ($model === null) { $model = new Robots(); } if ($model->value !== $this->robotsText || $model->value === "") { $model->value = $this->robotsText; $model->save(); } }
/** * Update robots.txt * @return string|\yii\web\Response * @throws \yii\web\NotFoundHttpException */ public function actionRobots() { $model = Robots::getModel(); if ($model === null) { $model = new Robots(); } if (Yii::$app->request->isPost) { if ($model->load(Yii::$app->request->post()) && $model->validate()) { $model->save(); return $this->refresh(); } } return $this->render('robots', ['model' => $model]); }