{"action":"created","issue":{"url":"https://api.github.com/repos/nilportugues/laravel5-jsonapi/issues/57","repository_url":"https://api.github.com/repos/nilportugues/laravel5-jsonapi","labels_url":"https://api.github.com/repos/nilportugues/laravel5-jsonapi/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/nilportugues/laravel5-jsonapi/issues/57/comments","events_url":"https://api.github.com/repos/nilportugues/laravel5-jsonapi/issues/57/events","html_url":"https://github.com/nilportugues/laravel5-jsonapi/issues/57","id":149129819,"number":57,"title":"Relationships and the jsonapi 1.0 standard doesn't match.","user":{"login":"rmarinleal","id":1807196,"avatar_url":"https://avatars.githubusercontent.com/u/1807196?v=3","gravatar_id":"","url":"https://api.github.com/users/rmarinleal","html_url":"https://github.com/rmarinleal","followers_url":"https://api.github.com/users/rmarinleal/followers","following_url":"https://api.github.com/users/rmarinleal/following{/other_user}","gists_url":"https://api.github.com/users/rmarinleal/gists{/gist_id}","starred_url":"https://api.github.com/users/rmarinleal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmarinleal/subscriptions","organizations_url":"https://api.github.com/users/rmarinleal/orgs","repos_url":"https://api.github.com/users/rmarinleal/repos","events_url":"https://api.github.com/users/rmarinleal/events{/privacy}","received_events_url":"https://api.github.com/users/rmarinleal/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nilportugues/laravel5-jsonapi/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":{"login":"nilportugues","id":550948,"avatar_url":"https://avatars.githubusercontent.com/u/550948?v=3","gravatar_id":"","url":"https://api.github.com/users/nilportugues","html_url":"https://github.com/nilportugues","followers_url":"https://api.github.com/users/nilportugues/followers","following_url":"https://api.github.com/users/nilportugues/following{/other_user}","gists_url":"https://api.github.com/users/nilportugues/gists{/gist_id}","starred_url":"https://api.github.com/users/nilportugues/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nilportugues/subscriptions","organizations_url":"https://api.github.com/users/nilportugues/orgs","repos_url":"https://api.github.com/users/nilportugues/repos","events_url":"https://api.github.com/users/nilportugues/events{/privacy}","received_events_url":"https://api.github.com/users/nilportugues/received_events","type":"User","site_admin":false},"milestone":null,"comments":8,"created_at":"2016-04-18T11:57:42Z","updated_at":"2016-05-11T16:17:26Z","closed_at":"2016-05-11T16:13:42Z","body":"Hi,\r\n\r\nI'm using your library in a project with Ember (and ember data) as a FrontEnd Framework , which incude a jsonapi extension.\r\n\r\nWell, ember data parse the relationships as the standard 1.0 specification, but your library doesn't fit to it.\r\n\r\nFirst off all, your library always returns the relations as an array of data objects, but the specification sais that the relationships of a model have to be a data object with as many objects (type and id) as records in the query.\r\n\r\nExample:\r\nlaravel5-jsonapi:\r\n`{\r\n  \"data\": [\r\n    {\r\n      \"type\": \"channels\",\r\n      \"id\": \"1\",\r\n      \"attributes\": {\r\n        \"company_id\": \"1\"\r\n      },\r\n      \"links\": {\r\n        \"self\": {\r\n          \"href\": \"http://localhost:55555/channels/1\"\r\n        }\r\n      },\r\n      \"relationships\": {\r\n        \"company\": [\r\n          {\r\n            \"data\": [\r\n              {\r\n                \"type\": \"companies\",\r\n                \"id\": \"1\"\r\n              }\r\n            ]\r\n          }\r\n        ],\r\n        \"platforms\": [\r\n          {\r\n            \"data\": [\r\n              {\r\n                \"type\": \"platforms\",\r\n                \"id\": \"1\"\r\n              }\r\n            ]\r\n          },\r\n          {\r\n            \"data\": [\r\n              {\r\n                \"type\": \"platforms\",\r\n                \"id\": \"1\"\r\n              },\r\n              {\r\n                \"type\": \"platforms\",\r\n                \"id\": \"2\"\r\n              }\r\n            ]\r\n          }\r\n        ] ...etc etc`\r\n\r\ninstead of \r\n\r\n`{\r\n  \"data\": [\r\n    {\r\n      \"type\": \"channels\",\r\n      \"id\": \"1\",\r\n      \"attributes\": {\r\n        \"company_id\": \"1\"\r\n      },\r\n      \"links\": {\r\n        \"self\": {\r\n          \"href\": \"http://localhost:55555/channels/1\"\r\n        }\r\n      },\r\n      \"relationships\": {\r\n        \"company\": {\r\n          \"data\": [\r\n            {\r\n              \"type\": \"companies\",\r\n              \"id\": \"1\"\r\n            }\r\n          ]\r\n        },\r\n        \"platforms\": {\r\n          \"data\": [\r\n            {\r\n              \"type\": \"platforms\",\r\n              \"id\": \"1\"\r\n            },\r\n            {\r\n              \"type\": \"platforms\",\r\n              \"id\": \"2\"\r\n            }\r\n          ]\r\n        } ...etc etc`\r\n\r\nI will correct it in the DataLinksHelper.php file, please consider to change it.\r\n\r\nAnother problem, and bigger, is than the output of the relationships node must match with the nature of the relation, for example, if the model has a relation with belongsTo, the output always will be a property data as an object (not an array) with the type and id properties of the relation:\r\nExample: \r\n`\"relationships\": {\r\n        \"company\": {\r\n          \"data\": {\r\n            \"type\": \"companies\",\r\n            \"id\": \"1\"\r\n          }\r\n        },...etc`\r\n\r\nIf the relaion is multiple record (such a hasMany) the output allwais have to be an array (also if the query only returns one object)\r\nExample:\r\n`{\r\n\"relationships\": {\r\n        \"platforms\": {\r\n          \"data\": [\r\n            {\r\n              \"type\": \"platforms\",\r\n              \"id\": \"1\"\r\n            }\r\n          ]\r\n        }...etc`\r\n\r\nOR\r\n`\r\n{\"relationships\": {\r\n        \"platforms\": {\r\n          \"data\": [\r\n            {\r\n              \"type\": \"platforms\",\r\n              \"id\": \"1\"\r\n            },\r\n            {\r\n              \"type\": \"platforms\",\r\n              \"id\": \"2\"\r\n            }\r\n          ]\r\n        }...etc`\r\n\r\nYou can see the specification here:\r\nhttp://jsonapi.org/format/#fetching-relationships"},"comment":{"url":"https://api.github.com/repos/nilportugues/laravel5-jsonapi/issues/comments/218510514","html_url":"https://github.com/nilportugues/laravel5-jsonapi/issues/57#issuecomment-218510514","issue_url":"https://api.github.com/repos/nilportugues/laravel5-jsonapi/issues/57","id":218510514,"user":{"login":"OskarD","id":6658382,"avatar_url":"https://avatars.githubusercontent.com/u/6658382?v=3","gravatar_id":"","url":"https://api.github.com/users/OskarD","html_url":"https://github.com/OskarD","followers_url":"https://api.github.com/users/OskarD/followers","following_url":"https://api.github.com/users/OskarD/following{/other_user}","gists_url":"https://api.github.com/users/OskarD/gists{/gist_id}","starred_url":"https://api.github.com/users/OskarD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OskarD/subscriptions","organizations_url":"https://api.github.com/users/OskarD/orgs","repos_url":"https://api.github.com/users/OskarD/repos","events_url":"https://api.github.com/users/OskarD/events{/privacy}","received_events_url":"https://api.github.com/users/OskarD/received_events","type":"User","site_admin":false},"created_at":"2016-05-11T16:17:26Z","updated_at":"2016-05-11T16:17:26Z","body":"I don't think this solves the second part of the issue:\r\n\r\n> Another problem, and bigger, is than the output of the relationships node must match with the nature of the relation, for example, if the model has a relation with belongsTo, the output always will be a property data as an object (not an array) with the type and id properties of the relation:\r\n> Example: \r\n> \"relationships\": { \"company\": { \"data\": { \"type\": \"companies\", \"id\": \"1\" } },...etc\r\n> \r\n> If the relaion is multiple record (such a hasMany) the output allwais have to be an array (also if the query only returns one object)\r\n> Example:\r\n> { \"relationships\": { \"platforms\": { \"data\": [ { \"type\": \"platforms\", \"id\": \"1\" } ] }...etc\r\n> \r\n> OR\r\n>  {\"relationships\": { \"platforms\": { \"data\": [ { \"type\": \"platforms\", \"id\": \"1\" }, { \"type\": \"platforms\", \"id\": \"2\" } ] }...etc\r\n> \r\n> You can see the specification here:\r\n> http://jsonapi.org/format/#fetching-relationships"}}