@include('hk.header')

{{ $page_title }}

User Activity Report

{{-- Filter Form --}}
{{-- Search User --}}
{{-- Start Date --}}
{{-- End Date --}}
{{-- Submit Button --}}
{{-- Data Table --}} @php $grandTotalCompanies = 0; $grandTotalProducts = 0; @endphp @foreach ($users as $user) @php // use the aggregated properties created in controller $companyDates = collect($user->company_dates); $productDates = collect($user->product_dates); // merge dates from both collections $dates = $companyDates ->pluck('date') ->merge($productDates->pluck('date')) ->unique() ->sort() ->values(); // reindex @endphp @if ($dates->isEmpty()) {{-- show a single empty row for user if no data --}} @else @foreach ($dates as $index => $date) @php // get counts from aggregated rows (null-safe) $companyRow = $companyDates->firstWhere('date', $date); $productRow = $productDates->firstWhere('date', $date); $companyCount = $companyRow->companies_count ?? 0; $productCount = $productRow->products_count ?? 0; $grandTotalCompanies += $companyCount; $grandTotalProducts += $productCount; $rowspan = $dates->count(); @endphp @if ($index === 0) @endif @endforeach @endif @endforeach
User Name Date No. of Companies Added No. of Products Added
{{ $user->name }} - 0 0
{{ $user->name }}{{ $date }} {{ $companyCount }} {{ $productCount }}
Total {{ $grandTotalCompanies }} {{ $grandTotalProducts }}
{{ $users->links() }}
@include('hk.footer')