/** * @return string|Response */ public function run() { /** @var Language $model */ $model = new Language(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->controller->redirect(['update', 'id' => $model->id]); } return $this->controller->render('create', ['model' => $model]); }
/** * @param int $id * @return Response * @throws NotFoundHttpException * @throws \Exception */ public function run($id) { /** @var Language $model */ $model = Language::findOne($id); if ($model === null) { throw new NotFoundHttpException('The requested language does not exist.'); } $model->delete(); return $this->controller->redirect(['view']); }
/** * @param $id * @return string|Response * @throws NotFoundHttpException */ public function run($id) { /** @var Language $model */ $model = Language::findOne($id); if ($model === null) { throw new NotFoundHttpException('The requested language does not exist.'); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->controller->redirect(['update', 'id' => $model->id]); } return $this->controller->render('update', ['model' => $model]); }
/** * @inheritdoc */ public function down() { $this->dropTable(Language::tableName()); }
/** * @return Language[] */ private function getLanguages() { return ArrayHelper::index(Language::find()->all(), 'locale'); }