Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Lumethys's avatar

Is it possible to use API resources with Repositories?

I'm new to Laravel, I have worked on some minor project with SSR Laravel, using Repository pattern, now that I want to try a backend API, The document encourage using API resources (JsonResources and ResourceCollection) to handle data given to the frontend. However, these resources work by injecting a Model into its constructor. And I cannot seem to find any mentioning of Repository Pattern in both the laravel document and the source code document. So my question is:

Is it possible to use Repository together with Resources? If yes, do the Controller access the Repository through the Resource, or access the Resource through the Repository?

Or, is the Resources a replacement for the Repository?

0 likes
0 replies

Please or to participate in this conversation.