Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Analytics::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['idanalytics' => $this->idanalytics, 'iduser' => $this->iduser, 'cdate' => $this->cdate, 'mdate' => $this->mdate]);
     $query->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'ip', $this->ip])->andFilterWhere(['like', 'session', $this->session])->andFilterWhere(['like', 'browser', $this->browser]);
     return $dataProvider;
 }
Example #2
0
 public function perform()
 {
     $ip = $this->args['ip'];
     $browser = $this->args['browser'];
     $url = $this->args['url'];
     $iduser = $this->args['iduser'];
     $session = $this->args['session'];
     $model = new Analytics();
     $model->url = $url;
     $model->ip = $ip;
     $model->iduser = $iduser ? $iduser : '******';
     $model->session = $session;
     $model->browser = $browser;
     $model->cdate = DATE_RFC3339;
     if ($model->save()) {
         echo "Saved Successfully!";
     } else {
         print_r($model->getErrors());
     }
     //echo "<pre>";print_r($model->attributes);
     # Run task
 }
 /**
  * Finds the Analytics model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Analytics the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Analytics::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }