/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CollectInteract::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if ($params != false && !empty($params['CollectInteractSearch'])) {
         //$b=$a;
         //=app::find()->where("name= :name",[':name'=>'QQ'])->one();
         //if()
         foreach ($params['CollectInteractSearch'] as $name => $value1) {
             if ($name === 'userid' && $value1 != null) {
                 $appinfo = User::findOne(['phone' => $params['CollectInteractSearch']['userid']]);
                 $this->userinc = $appinfo['id'];
                 if ($appinfo == null) {
                     $this->userinc = 0;
                 }
             }
         }
     }
     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, 'userid' => $this->userinc, 'created_at' => $this->created_at, 'msg' => $this->msg]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 public function actionCancelMsg()
 {
     $data = Yii::$app->request->post();
     $phone = User::findOne(['phone' => $data['phone']]);
     $info = CollectInteract::findOne(['userid' => $phone['id'], 'msg' => $data['msg']]);
     if ($info) {
         $info->delete();
         echo json_encode(array('flag' => 1, 'msg' => 'Cancel collect success!'));
     } else {
         echo json_encode(array('flag' => 0, 'msg' => 'Cancel collect fail!'));
     }
 }
 /**
  * Finds the CollectInteract model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CollectInteract the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CollectInteract::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCollectInteracts()
 {
     return $this->hasMany(CollectInteract::className(), ['userid' => 'id']);
 }