Open therealcljohn opened 8 years ago
@floh1111 I really need to document this more, as I have tested this already but maybe not all cases.
I believe additional code must be placed in here:
to make sure the usecase works, as this is clearly eloquent related.
I'm trying to unterstand how relationships in the jsonapi library work and defined a relationship in my transformer:
But this throws me the following error:
Could not find property roles in class App\\Models\\User because it does not exist.
. But it definetly does exist (note: laravel uses dynamic properties for relations and I can call $model->roles manually).I tracked this down to MappingFactory::getClassProperties() where you determine all properties of the used model by using the ReflectionClass. The problem is, that this method does only return all properties that represent columns in the database but it does not return the dynamic properties that laravel uses for relations.
I cannot digg this any further because this gets much deeper than my knowlegde. I'm especially interested in CREATE and DELETE of relations like described here http://jsonapi.org/format/#crud-updating-relationships and would be interested if this is possible with the jsonapi package.
Maybe you can give me a short feedback on how to use relations or if CREATE and DELETE on relations is supported or a hint on how to fix this issue. That would be great.