The pagination output of my Laravel is similar to a temporary laravel breakdown, but I need to change the data array for each object. My way out:

As you can see, the data object has 2 elements that I need to change.
My code is:
$items = $this->items() ->where('position', '=', null) ->paginate(15);
Which returns user elements with a pivot table, but I donโt like the way the pivot table is shown in JSON, so I decided to change the elements and organize each element using a pivot in front of the element.
To this end, I tried to use foreach
foreach ($items->data as $item) { }
which gives me an error, for some reason I don't know:
Undefined property: Illuminate\Pagination\LengthAwarePaginator::$data" status_code: 500
Any help?
source share