'Please assist i want to loop through two database tables and view them in a blade.I want records to appear according to dates with in different column

this is output screenshot

All i want is to show debit and credit according to dates. I want debit to show only if there's new record added and also credit to show only if there's changes in the accounts. I have used observer to check if column is dirty. here is my blade

                <table class="table table-striped">
                <thead style="background-color: #0b8a83;color:rgb(0, 0, 0);">
                    <th>Date</th>
                    <th>Description</th>
                    <th>Credit</th>
                    <th>Debit</th>
                    <th>Balance</th>
                </thead>
               
                    @foreach ($monthlyInst as $keyy)
                        <tr>
                           <td>{{ date('d/M/y', strtotime($keyy->updated_at)) }}</td>
                           <td></td>
                           <td></td>
                           <td>R {{ $keyy->Installment }}</td>
                           <td></td>
                       </tr> 
                    @endforeach

                    @foreach ($history as $account)            
                        <tr>
                            <td>{{ date('d/M/y', strtotime($account->updated_at)) }}</td>
                            <td>{{ $account->accountname }}</td>
                            <td>R {{ $account->newpaid }}</td>
                            <td></td>
                            <td>R {{ $account->newbal }}</td>
                            
                        </tr>
                    @endforeach 
                     <tr>
                    <td></td>
                    <td>Outstanding Balance</td>
                    <td></td>
                    <td></td>
                    <td><b>R {{ $totalbal }}</b></td>
                   </tr>
                
                   </table>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source