I got a little issue to solve. In my app I am handling with a lot of Models and each model does have something like:
- ModelResource
- ModelResourceCollection
- ModelResourceOverview
- ModelResourceOverviewCollection
The reason is: Sometimes I don't need all the information that are visible if I am using the ModelResource
- in this case I am calling the ModelResourceOverview
.
Example
PostResource
- title
- tags
- content
- author
Example
PostOverviewResource
- title
- author
As I have a lot of Models I have a huge number of ApiResource-Classes and I want to get rid of that.
I thought about using $this->when
in the Resource and pass something like "full" or "overview" to the request in the Controller.
Example
$data
= new PostResource($this->post);
So my question is: Is it the best way to add this to the request
or is there a handier/nicer way to handle this?