我目前安装了一个插件(https://github.com/antonioribeiro/tracker)
这是跟踪的事情,只有我想获得独特的访问者。我不知道如何从这个包中提取出来的。或者我应该如何自己制作一个。
我希望他们每月作为json对象返回。
如果有人可以帮我解决这个问题?
我使用tracker_sessions
表进行了尝试,但效果不佳。
Route::get('admin/api', function(){
$stats = DB::table('tracker_sessions')
->groupBy('created_at')
->orderBy('created_at', 'ASC')
->get([
DB::raw('created_at as y'),
DB::raw('COUNT(*) as b')
]);
return json_encode($stats);
});
返回类似这样的内容:
[{"y":"2016-05-22 21:17:17","b":1},{"y":"2016-05-22 21:17:27","b":1},{"y":"2016-05-22 21:17:28","b":2},{"y":"2016-05-22 21:17:29","b":1},{"y":"2016-05-22 21:17:31","b":1},{"y":"2016-05-22 21:17:33","b":1},{"y":"2016-05-22 21:18:10","b":1},{"y":"2016-05-22 21:18:11","b":2},{"y":"2016-05-22 21:18:13","b":1}]
一点都不好......
有人可以帮帮我吗?
谢谢!
答案 0 :(得分:1)
Route::get('admin/api', function(){
$stats = DB::table('tracker_sessions')
->groupBy(DB::raw('CAST(created_at as DATE)'))
->orderBy(DB::raw('CAST(created_at as DATE)'))
->get([
DB::raw('CAST(created_at as DATE) as y'),
DB::raw('COUNT(DISTINCT ip_column) as b')
]
);
return json_encode($stats);
});