예제 #1
0
 /**
  * Creates a new ReadingLog model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new ReadingLog();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
예제 #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;
     }
 }