{"action":"closed","issue":{"url":"https://api.github.com/repos/neomerx/json-api/issues/91","labels_url":"https://api.github.com/repos/neomerx/json-api/issues/91/labels{/name}","comments_url":"https://api.github.com/repos/neomerx/json-api/issues/91/comments","events_url":"https://api.github.com/repos/neomerx/json-api/issues/91/events","html_url":"https://github.com/neomerx/json-api/issues/91","id":115534668,"number":91,"title":"Inclusion of parent in Parent/Child relationship causes an error","user":{"login":"geniuscd","id":3702631,"avatar_url":"https://avatars.githubusercontent.com/u/3702631?v=3","gravatar_id":"","url":"https://api.github.com/users/geniuscd","html_url":"https://github.com/geniuscd","followers_url":"https://api.github.com/users/geniuscd/followers","following_url":"https://api.github.com/users/geniuscd/following{/other_user}","gists_url":"https://api.github.com/users/geniuscd/gists{/gist_id}","starred_url":"https://api.github.com/users/geniuscd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geniuscd/subscriptions","organizations_url":"https://api.github.com/users/geniuscd/orgs","repos_url":"https://api.github.com/users/geniuscd/repos","events_url":"https://api.github.com/users/geniuscd/events{/privacy}","received_events_url":"https://api.github.com/users/geniuscd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/neomerx/json-api/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/neomerx/json-api/labels/fixed","name":"fixed","color":"009800"}],"state":"closed","locked":false,"assignee":{"login":"neomerx","id":10420662,"avatar_url":"https://avatars.githubusercontent.com/u/10420662?v=3","gravatar_id":"","url":"https://api.github.com/users/neomerx","html_url":"https://github.com/neomerx","followers_url":"https://api.github.com/users/neomerx/followers","following_url":"https://api.github.com/users/neomerx/following{/other_user}","gists_url":"https://api.github.com/users/neomerx/gists{/gist_id}","starred_url":"https://api.github.com/users/neomerx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neomerx/subscriptions","organizations_url":"https://api.github.com/users/neomerx/orgs","repos_url":"https://api.github.com/users/neomerx/repos","events_url":"https://api.github.com/users/neomerx/events{/privacy}","received_events_url":"https://api.github.com/users/neomerx/received_events","type":"User","site_admin":false},"milestone":null,"comments":9,"created_at":"2015-11-06T16:10:16Z","updated_at":"2015-11-09T13:58:04Z","closed_at":"2015-11-09T13:58:04Z","body":"Hey,\r\nI have a 'Parent' named column inside the 'Category' table in my database. 'Parent' is foreign key to the same table ofcourse. ( pointing to 'ID' ).\r\nI'm trying to create a restful server, that follows jsonapi.org guidelines.\r\nand of course im implementing it using this superb library!\r\n\r\ni came across this issue where i can fetch one resource without any problem, the parent is included inside the 'inlcuded' attribute. but when im fetching an array of resources i got the following error message\r\n\r\n>PHP Catchable fatal error:  Argument 1 passed to Neomerx\\JsonApi\\Document\\Presenters\\ElementPresenter::setRelationshipTo() must be of the type array, null given, called in /vendor/neomerx/json-api/src/Document/Document.php on line 253 and defined in /vendor/neomerx/json-api/src/Document/Presenters/ElementPresenter.php on line 54\r\n\r\nMy table Category Structure ( example )\r\n\r\nID | Description | Parent\r\n----|----------------|----------\r\n1 | Main | null\r\n2 | Laptop | 1\r\n3 | PC | 1\r\n4 | Screen | 2\r\n5 | Big | 4\r\n6 | small | 4\r\n\r\nmy Category Model contains a property called 'Parent' of type *ModelCategory*\r\n*CategoryModel* gets filled using a *ModelHydrator* that gets its data from the *ModelMapper* ( provider)\r\n\r\nweird enough! when I'm fetching only one resource , its working normally. But when i try to fetch a collection, an error is thrown.\r\nI tried to change the Parent Model, swap it with another model , it worked...\r\n\r\n* maybe its an error that occurs only when including same model in the structure?\r\n* any clue? is anyone having this issue?\r\n\r\nps: i'm not allowed at the moment to upload the files that i'm working on, due to restrictions :/ but i will, after creating a sample that reproduce this error."}}