@php $gaColors = ['#3684c6', '#8b69cb', '#18875d']; $gaMax = max(1, ...array_values($analytics ?: [0])); $devices = ['mobile' => ['Điện thoại', '#3684c6'], 'desktop' => ['Máy tính', '#18875d']]; $chartUrl = $measurements->first()?->url; $chartRows = $measurements->where('url', $chartUrl)->sortBy('measured_at')->values(); $timestamps = $chartRows->map(fn ($row) => strtotime($row->measured_at)); $firstTime = $timestamps->min() ?? 0; $timeRange = ($timestamps->max() ?? 0) - $firstTime; $dateLabel = fn ($date) => \Illuminate\Support\Carbon::parse($date)->timezone('Asia/Ho_Chi_Minh')->format('d/m/Y H:i'); @endphp
Làm mới thống kê Đang tải số liệu truy cập…
@if ($analytics)
@foreach ($analytics as $label => $value)
{{ $label }}
{{ number_format($value, 0, ',', '.') }}
@endforeach
@else

Chưa có số liệu truy cập để hiển thị.

@endif
Đo trên điện thoại Đo trên máy tính Đang đo hiệu năng…
@if ($chartRows->isEmpty())

Chưa có kết quả đo.

@else
@foreach ($devices as $device => [$label, $color]) @php $latest = $chartRows->last(fn ($row) => $row->device === $device); @endphp
{{ $label }}
{{ $latest ? $latest->score . '/100' : 'Chưa đo' }}
@if ($latest) @endif
@endforeach
Lịch sử điểm hiệu năng

{{ $chartUrl }} · {{ $chartRows->count() }} lần đo

@foreach ([100, 75, 50, 25, 0] as $tick) @php $y = 24 + (100 - $tick) * 1.5; @endphp {{ $tick }} @endforeach @foreach ($devices as $device => [$label, $color]) @php $points = $chartRows->where('device', $device)->map(fn ($row) => [ 'x' => $timeRange > 0 ? 50 + round(600 * (strtotime($row->measured_at) - $firstTime) / $timeRange, 2) : 350, 'y' => 24 + (100 - (int) $row->score) * 1.5, 'row' => $row, ]); @endphp @if ($points->count() > 1) @endif @foreach ($points as $point) {{ $label }} · {{ $dateLabel($point['row']->measured_at) }} · {{ $point['row']->score }}/100 @endforeach @endforeach {{ $dateLabel($chartRows->first()->measured_at) }} @if ($timeRange > 0) {{ $dateLabel($chartRows->last()->measured_at) }} @endif
Xem chi tiết các lần đo
@foreach ($measurements as $measurement) @endforeach
Thời gianĐịa chỉ trangThiết bịĐiểm
{{ $dateLabel($measurement->measured_at) }} {{ $measurement->url }} {{ $devices[$measurement->device][0] ?? $measurement->device }} {{ $measurement->score }}/100
@endif