Support the ongoing development of Laravel.io →
API Laravel
Last updated 7 months 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

1
Solution selected by @pennywise96

Sign in to participate in this thread!

LaraJobs

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.

© 2022 Laravel.io - All rights reserved.