Hello I have 4 tables: Officials, Companies, Salaries and Discounts. I would like to introduce a kind of Holerite. My initial idea was to bring all the information together and treat the view as follows:
(NOTE: I'm using laravel blade)
@foreach ($funcionarios as $funcionario)
@php
$total_vencimentos = 0;
$total_descontos = 0;
$total_liquido = 0;
@endphp
@foreach ($vencimentos as $vencimento)
@if ($funcionario->id == $vencimento->funcionario_id)
imprime os vencimentos
@endif
@php $total_vencimentos += $vencimento->valor_adicionado @endphp
@endforeach
@foreach ($descontos as $desconto)
@if ($funcionario->id == $desconto->funcionario_id)
imprime os vencimentos
@endif
@php $total_vencimentos += $desconto->valor_descontado @endphp
@endforeach
@php
$total_liquido = ($total_vencimentos - $total_descontos);
@endphp
@endforeach
From this view a PDF is being generated. This code is working fine, but I worry if this process can get heavy with the increase of employees in the company, is there a better solution?
Thank you.