コード例 #1
0
 public function actionUser($id)
 {
     if (\Yii::$app->request->isAjax) {
         $model = UserLog::findOne(['id' => $id]);
         if (!$model) {
             throw new HttpException(404, \Yii::t('app', 'Page not found'));
         }
         return $this->renderAjax('_user', ['model' => $model]);
     }
     throw new HttpException(405, \Yii::t('app', 'Method not allowed'));
 }
コード例 #2
0
 /**
  * @param \insolita\redisman\events\ModifyEvent $event
  */
 public static function log($event)
 {
     $ip = \Yii::$app->request->getUserIP();
     $user = UserLog::findByIp($ip);
     if (!$user) {
         $user = new UserLog();
         $user->ip = $ip;
         $user->logincount = 1;
         $user->userAgent = \Yii::$app->request->getUserAgent();
         $user->lastvisit = time();
         $user->save(false);
     }
     $model = new ActionLog();
     $model->user_id = $user->id;
     $model->operation = $event->operation;
     $model->db = $event->db;
     $model->command = $event->command;
     $model->connection = $event->connection;
     $model->time = time();
     $model->save(false);
 }
コード例 #3
0
ファイル: User.php プロジェクト: dawei101/plants
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUserLogs()
 {
     return $this->hasMany(UserLog::className(), ['user_id' => 'id']);
 }