/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Upgrade::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(['id' => $this->id, 'user_id' => $this->user_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'phone_number', $this->phone_number])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'about', $this->about]);
     return $dataProvider;
 }
 /**
  * Finds the Upgrade model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Upgrade the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Upgrade::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionUpgrade()
 {
     $user = User::findOne(Yii::$app->request->post('user_id'));
     if (!$user) {
         return json_encode(['success' => false, 'data' => ['User not found.']]);
     }
     $upgrade = new Upgrade();
     $upgrade->user_id = $user->id;
     $upgrade->phone_number = Yii::$app->request->post('phoneNumber');
     $upgrade->address = Yii::$app->request->post('address');
     $upgrade->about = Yii::$app->request->post('about');
     if ($upgrade->save()) {
         return json_encode(['success' => true, 'data' => '']);
     } else {
         return json_encode(['success' => false, 'data' => $upgrade->getErrors()]);
     }
 }