Exemple #1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUserWorkings()
 {
     return $this->hasMany(UserWorking::className(), ['id' => 'id']);
 }
 public static function actionSaveworkingrecord()
 {
     $request = Yii::$app->request;
     $userID = $request->post('userID');
     $companyName = $request->post('companyname');
     $position = $request->post('position');
     $start = $request->post('start');
     $to = $request->post('serviceto');
     $model = new WorkingInformation();
     $userWorking = new UserWorking();
     $user = new User();
     /*print_r($this->pi_name);
       die();*/
     /*$pi = new PersonalInformation();
       $pi->load(Yii::$app->request->post());*/
     $model->wi_company_name = $companyName;
     $model->wi_position = $position;
     $model->wi_year_of_service_from = $start;
     $model->wi_year_of_service_to = $to;
     $model->save();
     /*print_r($model->save());
       die();*/
     if ($model->save() == 1) {
         $userWorking->id = $userID;
         $userWorking->wi_id = $model->wi_id;
         $userWorking->save();
         /*print_r($model->getErrors());
           die();*/
         Yii::$app->db->createCommand("UPDATE user SET working_status=2 WHERE id={$userID}")->execute();
     }
     // return $this->redirect(['index', 'id' => $model->id]);
 }