/** * Updates an existing UserJob model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $_id * @return mixed */ public function actionUpdate($id) { $modelUser = User::findOne($id); $modelUserJob = UserJob::findOne($id); if (!isset($modelUser, $modelUserJob)) { throw new NotFoundHttpException("The user was not found."); } if ($modelUser->load(Yii::$app->request->post()) && $modelUserJob->load(Yii::$app->request->post())) { $modelUserValidate = $modelUser->validate(); $modelUserJobValidate = $modelUserJob->validate(); if ($modelUserValidate && $modelUserJobValidate) { $modelUserJob->email = $modelUser->email; if ($modelUser->save(false) && $modelUserJob->save(false)) { if ($modelUserJob->role == 'seeker') { UserJobSeekerResume::updateAll(['nationality' => $modelUserJob->seeker_nationality, 'salary' => $modelUserJob->seeker_salary], ['_id' => $modelUserJob->_id]); } if (Yii::$app->request->post('save_type') !== 'apply') { return $this->redirect(['view', 'id' => (string) $modelUser->_id]); } } } } Yii::$app->view->title = Yii::t('yii', 'Update'); Yii::$app->view->params['breadcrumbs'][] = ['label' => Yii::t($this->module->id, 'Manage Members'), 'url' => ['index']]; Yii::$app->view->params['breadcrumbs'][] = Yii::$app->view->title; return $this->render('form', ['modelUser' => $modelUser, 'modelUserJob' => $modelUserJob]); }