-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to map different resources to the same model #610
Comments
In that case I think you should make a base class |
Another {json:api} implementation for Laravel has ability to do it. Docs: https://laraveljsonapi.io/docs/1.0/digging-deeper/proxies.html Repo: https://github.com/laravel-json-api/laravel. It's developed by author of this package and has a lot of new cool features and improvements. |
@michaelklopf the underlying encoder uses the class of the model to determine how to encode it - so it will not be able to distinguish between employees and consultants if you're using the same You'd need to use a separate model class for both - as @ben221199 suggests, having a Otherwise you need some sort of proxy implementation. I've implemented that for the next generation of this package - which is the |
Thank you guys. I still have to look at the new version and find out how migration would work out. And thanks for bringing in the alternative solutions. |
Hi,
I'm currently trying to resolve an issue I have with how the API is structured. We have two different kind of users that are appearing in relationships. I'm looking for a way to differentiate the two user groups with resources. Something like this
When querying the relationship
/api/assignments/1/created-by
I would like to receive the underlying user object as"type": "employees"
and for/api/assignments/1/supported-by
as"type": "consultants"
.Employees and consultants have their own schemas and adapters, but for both resources I'm getting
"type": "employees"
.Is there a solution in this package, or do I need to make a new model class for the different user types?
The text was updated successfully, but these errors were encountered: