@php use App\Models\Pop; $managerIsNewOrOld = ''; $total_active_clients_new = 0; $total_active_clients_old = 0; $total_not_active_clients_new = 0; $total_not_active_clients_old = 0; @endphp @foreach ($users->resellers as $reseller) @php $new_resellers_ids = $users ->resellers() ->whereBetween('resellers.created_at', [$start, $end]) ->where('resellers.id', $reseller->id) ->first(); $pops = Pop::where('reseller_id', $reseller->id)->pluck('id'); $active_clients = $clients->whereIn('pop_id', $pops)->where('clients_status', 'active')->count(); $not_active_clients = $clients ->whereIn('pop_id', $pops) ->where('clients_status', '!=', 'active') ->count(); if ($new_resellers_ids == null) { $managerIsNewOrOld = 'Old'; $total_active_clients_old += $active_clients; $total_not_active_clients_old += $not_active_clients; } else { $managerIsNewOrOld = 'New'; $total_active_clients_new += $active_clients; $total_not_active_clients_new += $not_active_clients; } @endphp @if ($managerIsNewOrOld == 'Old') @else @endif @endforeach
Manager Id Manager Name Manager Type New Id (Active) Updated Id (Active) New Id (Not Active) Updated Id (Not Active)
{{ $reseller->id }} {{ $reseller->name }} {{ $managerIsNewOrOld }}0 {{ $active_clients }} 0 {{ $not_active_clients }}{{ $active_clients }} 0 {{ $not_active_clients }} 0
Total ({{ $users->resellers->count() }}) {{ $total_active_clients_new }} {{ $total_active_clients_old }} {{ $total_not_active_clients_new }} {{ $total_not_active_clients_old }}