-
Notifications
You must be signed in to change notification settings - Fork 38
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
Relationships JSON #75
Conversation
3 similar comments
Please add a test demonstrating and exercising this. Thanks. |
4 similar comments
Ok, I have a bunch of problems with this. I asked for tests because the original PR was unclear as to exactly what it does. Here are my main issues, in order of importance:
I would rather add documentation on how to achieve what you've done generically than change code that people are already depending on. Another option would be to make a subclass of this called something like ToJSON::WithRelated, but even then, it is strange to include What do you think? |
Closing this since it's been two months. |
When we use relationships - your TO_JSON won't process it.
For example: if table 'users' and 'plans' with relationship user.plan -> plan.id then, when we do $user->TO_JSON we'll receive this: {"user_id":1,"plan":MyAPP::Result::Plan=HASH(0x00000000)}
With this patch result will be like this:
{"user_id":1,"plan":{"id":1,"name":"wow"}}