R
R
Ramm2017-01-13 14:57:59
Laravel
Ramm, 2017-01-13 14:57:59

How to paginate a modified collection in Laravel 5?

This code, when the barcode field matches in both arrays, adds the $r_item array to $task->items in the data field,

foreach ($task->items as $key => $item){
            foreach ($r_items as $r_item) {
                if ($item->barcode == $r_item->barcode) {
                    $item->data = $r_item;
                }
            }
        }

Everything works, but when I call $task->items()->paginate(15), my data field is not there, how to make pagination, but to have a data field?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2017-01-13
@Sanasol

It is necessary to filter during selection from basis, instead of after.
If I understand correctly what you have going on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question