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


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.


Sign in to participate in this thread!


Your banner here too?


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

Your logo here?

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

© 2024 - All rights reserved.