fakhrani/visitor

在数据库中记录访客信息,页面点击数,并为 Laravel 5 生成访问计数器

dev-main 2022-12-25 07:51 UTC

This package is not auto-updated.

Last update: 2024-09-29 16:00:46 UTC


README

安装

安装 Visitor 的推荐方式是通过 composer。

步骤 1

运行

composer require fakhrani/visitor

步骤 2

如果你的 Laravel 版本小于 5.5,将其添加到 app/config/app.php 中服务提供者列表

	Fakhrani\Visitor\VisitorServiceProvider::class

的列表中

步骤 3

运行迁移访客表

php artisan vendor:publish

然后

php artisan migrate

迁移访客表

同时将 config.php 复制到 /config 目录下

/config/visitor.php

根据需要进行自定义

步骤 5(可选)

访问 http://dev.maxmind.com/geoip/geoip2/geolite2/

下载 GeoLite2-City.mmdb

将其放置在(创建 geo 目录)

storage/geo/

或你想要的任何地方,只需调整包配置以反映新位置即可,它用于定位访客

用法

Visitor::log();   //log in db visitor ip, geo location, hit counter


Visitor::get();
Visitor::get( $ip );   //fetch ip record



Visitor::forget( $ip ); //delete ip from log


Visitor::has( $ip );   // checkk if visitor ip exist in log


Visitor::count()  // return count of all site registred unique visitors


Visitor::all();  // all records as array

Visitor::all(true);  // all records as collection


Visitor::clicks(); //total of all clicks


Visitor::range($date_start, $date_end); // visitors count in a date range;

###致谢 此产品使用 MaxMind 创建的 GeoLite2 数据,在可用时。

享受!