@php $hours24 = $this->last24Hours; $peak24 = max(1, collect($hours24)->max('bytes')); $daily = $this->dailyUsage; $dailyPeak = max(1, collect($daily)->max(fn ($d) => $d['up'] + $d['down'])); $peakHours = $this->peakHours; $peakHourMax = max(1, max($peakHours)); $trend = $this->paymentTrend; $trendPeak = max(1, collect($trend)->max('total')); $busiest = array_search(max($peakHours), $peakHours, true); $dayTotal = collect($daily)->sum(fn ($d) => $d['up'] + $d['down']); $activeDays = collect($daily)->filter(fn ($d) => $d['up'] + $d['down'] > 0)->count(); @endphp {{-- Live counters. Refreshed on a poll rather than streamed: the numbers come from the accounting poller, which reads the router once a minute. --}}
{{ __('Live from :router', ['router' => $current?->router?->router_name ?: __('the network')]) }} @if ($stats['is_live']) {{ __('streaming') }} @endif

{{ $stats['is_live'] ? __('Connected :for', ['for' => $stats['live_since']?->diffForHumans(null, true, true)]) : __('Not connected right now') }}

{{ __('Download') }} {{ bytes_human($live?->bytes_out ?? 0) }} {{ __('this session') }}
{{ __('Upload') }} {{ bytes_human($live?->bytes_in ?? 0) }} {{ __('this session') }}
{{ __('Last 24 hours') }} {{ bytes_human($peak24) }} {{ __('peak hour') }}
@foreach ($hours24 as $slot)
@endforeach
{{ $hours24[0]['label'] }} {{ end($hours24)['label'] }}
{{ __('Session up') }}
{{ $stats['live_since']?->diffForHumans(null, true, true) ?: '—' }}
{{ __('This session') }}
{{ bytes_human(($live?->bytes_in ?? 0) + ($live?->bytes_out ?? 0)) }}
{{ __('This month') }}
{{ bytes_human($stats['bytes_month']) }}
{{ __('Connection') }}
{{ $live?->ip_address ?: '—' }}
{{ __('Payment trend') }}

{{ __('Monthly payments · last 12 months') }}

@foreach ($trend as $month)
{{ $month['label'] }}
@endforeach
{{ __('Lifetime') }}
{{ money($stats['spent'], 0) }}
{{ __('Purchases') }}
{{ $stats['purchases'] }}
{{ __('Last payment') }}
{{ $this->sessions->where('amount', '>', 0)->first()?->created_at->format('M j, g:i A') ?: '—' }}
{{ __('Data usage') }}

{{ __('Daily traffic · this month so far') }}

@foreach ($daily as $day) @php $total = $day['up'] + $day['down']; @endphp
{{-- Upload stacked on download, so the split is visible without a second chart. --}}
@endforeach
{{ __('Download') }} {{ __('Upload') }}
{{ __('This month') }}
{{ bytes_human($dayTotal) }}
{{ __('Peak day') }}
{{ bytes_human($dailyPeak) }}
{{ __('Average per active day') }}
{{ $activeDays > 0 ? bytes_human((int) ($dayTotal / $activeDays)) : '—' }}
{{ __('Peak usage hours') }}

{{ __('Average traffic by hour of day · last 30 days') }}

{{ __('Quiet') }} @foreach ([0.12, 0.35, 0.65, 1] as $step) @endforeach {{ __('Heavy') }}
@foreach ($peakHours as $hour => $bytes) @php $weight = $bytes > 0 ? max(0.15, sqrt($bytes / $peakHourMax)) : 0; @endphp 0) style="background: rgba(33,208,122,{{ round($weight, 2) }});" @endif title="{{ sprintf('%02d:00', $hour) }} — {{ bytes_human($bytes) }}"> @endforeach
@foreach ([0, 6, 12, 18, 23] as $mark) {{ sprintf('%02d', $mark) }} @endforeach
{{ __('Peak hour') }}
@if (max($peakHours) > 0) {{ sprintf('%02d:00 — %02d:00', $busiest, ($busiest + 1) % 24) }} @else — @endif
{{ __('Peak average') }}
{{ bytes_human(max($peakHours)) }}
{{ __('Usage pattern') }}
@if (max($peakHours) === 0) — @elseif ($busiest < 12) {{ __('Morning user') }} @elseif ($busiest < 18) {{ __('Afternoon user') }} @else {{ __('Evening user') }} @endif
@if ($dayTotal === 0) {{-- Counters only started when accounting was switched on, so an established customer can legitimately show nothing here. --}}

{{ __('Traffic is measured from the moment accounting started collecting. Sessions before that were never counted, so history begins there rather than at signup.') }}

@endif