public function search($params)
 {
     $query = UserVisitLog::find();
     $query->joinWith(['user']);
     // Don't let non-superadmin view superadmin activity
     if (!Yii::$app->user->isSuperadmin) {
         $query->andWhere([User::tableName() . '.superadmin' => 0]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->request->cookies->getValue('_grid_page_size', 20)], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if ($this->visit_time) {
         $tmp = explode(' - ', $this->visit_time);
         if (isset($tmp[0], $tmp[1])) {
             $query->andFilterWhere(['between', static::tableName() . '.visit_time', strtotime($tmp[0]), strtotime($tmp[1])]);
         }
     }
     $query->andFilterWhere([$this->tableName() . '.id' => $this->id]);
     $query->andFilterWhere(['like', User::tableName() . '.username', $this->user_id])->andFilterWhere(['like', static::tableName() . '.ip', $this->ip])->andFilterWhere(['like', static::tableName() . '.os', $this->os])->andFilterWhere(['like', static::tableName() . '.browser', $this->browser])->andFilterWhere(['like', static::tableName() . '.language', $this->language]);
     return $dataProvider;
 }
Example #2
0
<?php

return ['vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'bootstrap' => ['comments', 'yee'], 'language' => 'en', 'sourceLanguage' => 'en-US', 'modules' => ['yee' => ['class' => 'yeesoft\\Yee'], 'comments' => ['class' => 'yeesoft\\comments\\Module', 'userModel' => 'yeesoft\\models\\User']], 'components' => ['settings' => ['class' => 'yeesoft\\components\\Settings'], 'cache' => ['class' => 'yii\\caching\\FileCache'], 'user' => ['class' => 'yeesoft\\components\\User', 'on afterLogin' => function ($event) {
    \yeesoft\models\UserVisitLog::newVisitor($event->identity->id);
}]]];