traffic sorting

This commit is contained in:
Čarodej
2021-12-01 15:13:02 +01:00
parent dd3e477593
commit 8242ba860f
2 changed files with 153 additions and 6 deletions

View File

@@ -101,27 +101,28 @@ class UserStorageResource extends JsonResource
{
$period = now()->subDays(45)->endOfDay();
$uploadMax = \DB::table('traffic')
$uploadMax = DB::table('traffic')
->where('user_id', $this->id)
->where('created_at', '>', $period)
->max('upload');
$downloadMax = \DB::table('traffic')
$downloadMax = DB::table('traffic')
->where('user_id', $this->id)
->where('created_at', '>', $period)
->max('download');
$trafficRecords = \DB::table('traffic')
$trafficRecords = DB::table('traffic')
->where('user_id', $this->id)
->where('created_at', '>', $period)
->orderBy('created_at')
->get();
$downloadTotal = \DB::table('traffic')
$downloadTotal = DB::table('traffic')
->where('user_id', $this->id)
->where('created_at', '>', $period)
->sum('download');
$uploadTotal = \DB::table('traffic')
$uploadTotal = DB::table('traffic')
->where('user_id', $this->id)
->where('created_at', '>', $period)
->sum('upload');