duckz1209's avatar

other methods for all()

is there any other method for all()? im getting a big collection and paginate is not working. it only gets the first page of pagination

heres my code

controller:
$payments = Payment::paginate(20);

blade:
    <?php
foreach($payments as $payment){
      
    if($client->id == $payment->id){
        $pay+= $payment->loan_interest+$payment->loan_amount+$payment->loan_cbu;
                            }
                        }
    $balance = $cap-$pay-$rev;
    ?>

<tr>
    <td>{{$balance}}</td>
</tr>
0 likes
7 replies
Nakov's avatar

Can you explain why paginate is not working?

There are other methods for sure, you can use take but that's like using limit, you will not be able to get the next page of 20 results.

Payment::take(20)->get();
munazzil's avatar

Check in blade as like below the tr tags,

   <div>{{ $payments ->links() }}</div>

and can you show what is the exact error do you getting?

duckz1209's avatar

yeah thats why i want to know how can i get the next page result. im not using it as a display

duckz1209's avatar

im using $payments to get all clients balance

bobbybouwmann's avatar

@duckz1209 chunk would split the collection in smaller parts, but in the end you still have the full collection so it has the same performance as all.

Can you maybe explain what you're trying to achieve?

1 like

Please or to participate in this conversation.