Creating resources with relations ignores relations
OskarD opened this issue · comments
An example of creating a resource with a relation can be found here: http://jsonapi.org/format/#crud-creating
{
"data": {
"type": "photos",
"attributes": {
"title": "Ember Hamster",
"src": "http://example.com/images/productivity.png"
},
"relationships": {
"photographer": {
"data": { "type": "people", "id": "9" }
}
}
}
}
In this example, a relationship between the newly created photos
resource and an existing photographer
should be created. This is not the case, at least with many-to-many relations (That's all I've tested).
With the current implementation, the photos
resource is created without the relation.
@OskarD This is eloquent related once again.
Looks like editing https://github.com/nilportugues/laravel5-jsonapi/blob/master/src/NilPortugues/Laravel5/JsonApi/Actions/CreateResource.php and overriding the CreateResource
https://github.com/nilportugues/laravel5-jsonapi/releases/tag/2.3.0 may fix this. Mind checking?
Sorry @nilportugues I had to abandon the library to make a deadline :( I will let you know if I get the chance to pick it up again!
@OskarD no problem
BTW did you ever try https://github.com/nilportugues/laravel5-jsonapi#postputpatch-with-relationships ?
It's the way to do it.