I have the follow collection of the $session object returned from my model: Sample item of Collection
I have the following table, which all is good, except the totals after each tutor. The blue row is each tutor, which lists all the student that the tutor tutors. Sample of Table
I have the following Blade Code:
<table id="income-by-date-table" class="table table-bordered table-striped hover"
style="width:100%">
@php $tutor_id = '';
$total_sessions = 0;
$total_gross_income = 0;
$total_client_gross_income = 0;
$total_tutor_gross_income = 0;
@endphp
@foreach($sessions as $tutor)
@if($tutor->tutor_id != $tutor_id)
<thead>
<tr>
<td colspan="6" class="text-bold"
style="background-color: #3C8DBC;color: #fff;">
</td>
</tr>
<tr>
<th>Student</th>
<th>Subject</th>
<th>Total Sessions</th>
<th>Client Rate</th>
<th>Advisor Rate</th>
<th>Gross Income</th>
</tr>
</thead>
@php $tutor_id = $tutor->tutor_id; @endphp
@endif
@foreach($sessions as $student)
@if($tutor->tutor_id === $student->tutor_id)
@if($tutor->student_id === $student->student_id)
@php
$total_sessions += $student->total_sessions;
$gross_income = $student->total_client_rate - $student->total_tutor_rate;
$total_client_gross_income += $student->total_client_rate;
$total_tutor_gross_income += $student->total_tutor_rate;
$total_gross_income += $student->total_client_rate - $student->total_tutor_rate;
@endphp
<tr>
<td style="padding-left: 20px;">
</td>
<td></td>
<td class="text-right"></td>
<td class="text-right">$</td>
<td class="text-right">$</td>
<td class="text-right">$</td>
</tr>
@endif
@endif
@if("NEED TO FILTER FOR THE TOTALS")
<tr style="background-color: #DFE3E8">
<td class="text-center text-bold">Total Gross Income</td>
<td></td>
<td class="text-right text-bold"></td>
<td class="text-right text-bold">$</td>
<td class="text-right text-bold">$</td>
<td class="text-right text-bold">$</td>
</tr>
@php
$total_sessions = 0;
$total_client_gross_income = 0;
$total_tutor_gross_income = 0;
$total_gross_income = 0;
@endphp
@endif
@endforeach
@endforeach
</table>
I would like to have the totals after each tutor. After much research, trying different ways, and wasting a lot of time, I still can't seem to find a solution.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2NGAzo7
via IFTTT
Aucun commentaire:
Enregistrer un commentaire