public function actionAjaxextension()
 {
     if (!empty($_POST)) {
         $vocabulary = new Vocabulary();
         $vocabulary->german = $_POST['word'];
         $vocabulary->russian = $vocabulary->translate($_POST['word']);
         $vocabulary->context = $_POST['sentence'];
         if ($vocabulary->save()) {
             echo "the word: \"{$vocabulary->german}\" has been saved as: \"{$vocabulary->russian}\" in you vocabulary";
         }
     }
 }
 /**
  * Creates a new Vocabulary model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Vocabulary();
     if (Yii::$app->request->post()) {
         $postData = Yii::$app->request->post();
         $postData['Vocabulary']['russian'] = $model->translate($postData['Vocabulary']['german']);
         if ($model->load($postData) && $model->save()) {
             $trainings = new Trainings();
             $trainings->wordId = $model->wordId;
             $trainings->userId = 1;
             // hardcoded for one user
             $trainings->translateWord = 1;
             $trainings->wordTranslate = 1;
             $trainings->typeWord = 1;
             $trainings->flashCards = 1;
             $trainings->insert();
             return $this->redirect(['view', 'id' => $model->wordId]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }