/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = WorkingInformation::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['wi_id' => $this->wi_id]); $query->andFilterWhere(['like', 'wi_company_name', $this->wi_company_name])->andFilterWhere(['like', 'wi_position', $this->wi_position])->andFilterWhere(['like', 'wi_year_of_service_from', $this->wi_year_of_service_from])->andFilterWhere(['like', 'wi_year_of_service_to', $this->wi_year_of_service_to]); return $dataProvider; }
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]); }
/** * @return \yii\db\ActiveQuery */ public function getWi() { return $this->hasOne(WorkingInformation::className(), ['wi_id' => 'wi_id']); }