<h3>
@php $i = 0 @endphp
@foreach ($dischargePatients as $patient)
@if ($patient->GetPatientDistrict() == auth()->user()->district_assigned)
{{ $i }}
@else
{{ $i }}
@endif
@endforeach
</h3>
the value i get was "0 0 0" , what i need is 3. there are actually 4 which 3 is true and 1 false i hope you understand my question, thanks in advance
CodePudding user response:
Its better to count the users in the patientDistrict in the controller and give the view the new variable
$patientsInDistrict = collect($dischargePatients)
->filter(function($patient) {
return $patient->GetPatientDistrict() == auth()->user()->district_assigned;
})
->count()
...
return view('your-view', ['dischargePatients' => $dischargePatients, 'patientsInDistrict' => $patientsInDistrict]);
That gives you a new variable in your view
{{ $patientsInDistrict }}