Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ReadingLog::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, 'aid' => $this->aid, 'uid' => $this->uid, 'status' => $this->status, 'create_at' => $this->create_at, 'update_at' => $this->update_at]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * 忽略全部消息
  * @param $msa_arr
  * @param $uid
  * @return array
  */
 public static function ignore_all($msa_arr, $uid)
 {
     if (!is_array($msa_arr)) {
         $result = array('errorNum' => '1', 'errorMsg' => '请以数据形式传参', 'data' => null);
         return $result;
     }
     $arr_length = count($msa_arr);
     if ($arr_length) {
         foreach ($msa_arr as $key => $value) {
             $flag = ReadingLog::find()->where(['uid' => $uid, 'aid' => $value])->one();
             if (!$flag) {
                 //如果不存在阅读记录
                 $log = new ReadingLog();
                 $log->aid = $value;
                 $log->uid = $uid;
                 $log->status = ReadingLog::STATUS_ACTIVE;
                 $log->save();
             }
             continue;
         }
         $result = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
         return $result;
     } else {
         $result = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
         return $result;
     }
 }
Esempio n. 3
0
 /**
  * Finds the ReadingLog model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ReadingLog the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ReadingLog::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }