Xboard/app/Http/Controllers/V1/User/StatController.php

27 lines
729 B
PHP
Raw Normal View History

2023-11-17 01:44:01 -05:00
<?php
namespace App\Http\Controllers\V1\User;
use App\Http\Controllers\Controller;
use App\Http\Resources\TrafficLogResource;
2023-11-17 01:44:01 -05:00
use App\Models\StatUser;
use App\Services\StatisticalService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class StatController extends Controller
{
public function getTrafficLog(Request $request)
{
$startDate = now()->startOfMonth()->timestamp;
$records = StatUser::query()
2025-01-06 12:20:11 -05:00
->where('user_id', $request->user()->id)
->where('record_at', '>=', $startDate)
2023-11-17 01:44:01 -05:00
->orderBy('record_at', 'DESC')
->get();
$data = TrafficLogResource::collection(collect($records));
return $this->success($data);
2023-11-17 01:44:01 -05:00
}
}