Hello everybody,
while developing a personal package I've found a strange issue.
My goal is to return an array from a controller, thats contains to element:
['columns'] => is an array of array, nothing special
['data'] => is the result of a paginated query builder (spatie laravel-query-builder/v3).
What i can see is that data contains an ApiResource, i lost the pagination properties, and get only the users section.
I tried also this:
If i execute
$users = QueryBuilder::for(User::class)->with('roles')->paginate();
return UserResource::collection($users);
Everything went good, andi get data with users and pagination properties!
But if i want to introduce ApiResource like this:
$users = QueryBuilder::for(User::class)->with('roles')->paginate();
return [
'columns' => [],
'users' => UserResource::collection($users)
];
I get columns, and users. Inside users i get directly the users Resource, without pagination properties.
Am i missing something?
thanks!