Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = QrcodeScanlog::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, 'qrcode_id' => $this->qrcode_id, 'terminal_type' => $this->terminal_type, 'scan_at' => $this->scan_at]);
     $query->andFilterWhere(['like', 'scan_ip', $this->scan_ip]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * Finds the QrcodeScanlog model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return QrcodeScanlog the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = QrcodeScanlog::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 3
0
 public function scanLog($qrcodeId)
 {
     $record = $this->findOne(['id' => $qrcodeId]);
     if (!$record) {
         return false;
     }
     $record['scans'] += 1;
     $record['updated_at'] = time();
     $record->save();
     $logModel = new QrcodeScanlog();
     $logModel->qrcode_id = $qrcodeId;
     $logModel->terminal_type = 1;
     $logModel->scan_ip = \Yii::$app->request->getUserIP();
     $logModel->scan_at = time();
     return $logModel->insert();
 }