do not return strings, but int

This commit is contained in:
socksprox
2025-11-29 15:10:06 +01:00
parent 0446f88e9e
commit c327fecb49
2 changed files with 14 additions and 2 deletions

View File

@@ -29,7 +29,12 @@ class StatController extends Controller
->where('record_at', '>=', $startDate)
->groupBy(['user_id', 'server_rate', 'record_at', 'record_type'])
->orderBy('record_at', 'DESC')
->get();
->get()
->map(function ($item) {
$item->u = (int) $item->u;
$item->d = (int) $item->d;
return $item;
});
$data = TrafficLogResource::collection($records);
return $this->success($data);

View File

@@ -255,7 +255,14 @@ class StatController extends Controller
// Manual pagination for grouped query
$total = (clone $query)->get()->count();
$data = $query->skip(($page - 1) * $pageSize)->take($pageSize)->get();
$data = $query->skip(($page - 1) * $pageSize)->take($pageSize)->get()
->map(function ($item) {
$item->u = (int) $item->u;
$item->d = (int) $item->d;
$item->created_at = (int) $item->created_at;
$item->updated_at = (int) $item->updated_at;
return $item;
});
return [
'data' => $data,