Support the ongoing development of Laravel.io →
API Eloquent Laravel
Last updated 2 years ago.
0

Hey,

specifying the controller like this should be fine:

Route::get('/clients', function () {
    $clients = B3Clients::with('group')->paginate();
    return ClientResource::collection($clients);
});

Also, how does your model B3Clients look like? Do you have any hidden fields defined in there? Also the GroupResource and the group model?

The error message itself says that there's a query builder instance passed to the collection or some other class where it shouldn't. Resources expect an array or a collection (or likewise) object.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.