Support the ongoing development of Laravel.io →
API Laravel
Last updated 1 year ago.
0
moderator Solution

You cannot resolve a resource from the container. It needs to be instantiated with an Eloquent model as a dependency. You need to use it with a collection like this:

$result = $this->model->all();
return Resource::collection($result);

Please read the docs carefully: https://laravel.com/docs/9.x/eloquent-resources

pennywise96 liked this reply

1
Solution selected by @pennywise96

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.