@php
// Ensure variables exist for all roles
$topProductLabels = [];
$topProductCounts = [];
// Only populate them if user is an admin
if (auth()->user()->role === 'admin') {
$topProductLabels = $topProducts->pluck('name')->toArray();
$topProductCounts = $topProducts->pluck('total_quantity_sold')->toArray();
}
@endphp
@if (auth()->user()->role === 'admin')