2023-11-17 01:44:01 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\V1\User;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2023-12-10 04:53:31 -05:00
|
|
|
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)
|
|
|
|
{
|
2024-10-06 21:55:19 -04:00
|
|
|
$startDate = now()->startOfMonth()->timestamp;
|
2023-12-10 04:53:31 -05:00
|
|
|
$records = StatUser::query()
|
2025-01-06 12:20:11 -05:00
|
|
|
->where('user_id', $request->user()->id)
|
2023-12-10 04:53:31 -05:00
|
|
|
->where('record_at', '>=', $startDate)
|
2023-11-17 01:44:01 -05:00
|
|
|
->orderBy('record_at', 'DESC')
|
|
|
|
->get();
|
|
|
|
|
2023-12-10 04:53:31 -05:00
|
|
|
$data = TrafficLogResource::collection(collect($records));
|
|
|
|
return $this->success($data);
|
2023-11-17 01:44:01 -05:00
|
|
|
}
|
|
|
|
}
|