i found out a way by someone asking a question, of a way of producing subtotals, i now just wanted to sum values between two tables , in the code from the person i tested and it works perfectly, i just wanted to aggregate more one table to any of the querys , it's summing on the blade.
//resumed controller
public function index() {
$emphayas = DB::select('select * from emphayas');
$treasuries = DB::select('select * from treasuries');
return view('database',['emphayas'=>$emphayas,
'treasuries'=>$treasuries,
]);}
-----------------------------------------------------------------
//resumed blade
<table >
<tr>
<th >Total</th>
<td >available_for_use_month</td>
</tr>
@foreach ($emphayas as $emphaya)
<tr>
<td></td>
<td>{{ $emphaya->available_for_use_month}}</td>
</tr>
@endforeach
<tr>
<td>Total</td>
<td>{{ \App\Models\Emphaya::sum('available_for_use_month') }}
</tr>
</table>
<table >
<tr>
<th >Total</th>
<td >available_for_use_month</td>
</tr>
@foreach ($treasuries as $treasury)
<tr>
<td></td>
<td>{{ $treasury->available_for_use_month}}</td>
</tr>
@endforeach
<tr>
<td>Total</td>
<td>{{ \App\Models\Treasury::sum('available_for_use_month') }}
</tr>
</table>
in this case what i want to do is connect the total of treasury to emphyas
CodePudding user response:
<tr>
<td>Total</td>
<td>{{ \App\Models\Emphaya::sum('available_for_use_month') \App\Models\Treasury::sum('available_for_use_month') }}
</tr>