You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to unterstand how relationships in the jsonapi library work and defined a relationship in my transformer:
public function getRelationships()
{
return [
'roles' => [
'self' => 'http://example.com/user/{userId}/roles',
]
];
}
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: