mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update: user statistical
This commit is contained in:
parent
c6fbb89452
commit
3b1159187f
@ -4,6 +4,7 @@ namespace App\Http\Controllers\User;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\StatUser;
|
use App\Models\StatUser;
|
||||||
|
use App\Services\StatisticalService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
@ -11,7 +12,10 @@ class StatController extends Controller
|
|||||||
{
|
{
|
||||||
public function getTrafficLog(Request $request)
|
public function getTrafficLog(Request $request)
|
||||||
{
|
{
|
||||||
$builder = StatUser::select([
|
$statService = new StatisticalService();
|
||||||
|
$statService->setStartAt(strtotime(date('Y-m-d')));
|
||||||
|
$statService->setUserStats();
|
||||||
|
$stats = StatUser::select([
|
||||||
'u',
|
'u',
|
||||||
'd',
|
'd',
|
||||||
'record_at',
|
'record_at',
|
||||||
@ -20,9 +24,17 @@ class StatController extends Controller
|
|||||||
])
|
])
|
||||||
->where('user_id', $request->user['id'])
|
->where('user_id', $request->user['id'])
|
||||||
->where('record_at', '>=', strtotime(date('Y-m-1')))
|
->where('record_at', '>=', strtotime(date('Y-m-1')))
|
||||||
->orderBy('record_at', 'DESC');
|
->orderBy('record_at', 'DESC')
|
||||||
|
->get()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$stats = array_merge($stats, $statService->getStatUserByUserID($request->user['id']));
|
||||||
|
usort($stats, function ($a, $b) {
|
||||||
|
return $b['record_at'] - $a['record_at'];
|
||||||
|
});
|
||||||
|
|
||||||
return response([
|
return response([
|
||||||
'data' => $builder->get()
|
'data' => $stats
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Library;
|
|
||||||
|
|
||||||
|
|
||||||
class V2ray
|
|
||||||
{
|
|
||||||
protected $config;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->config = new \StdClass();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user