{"action":"created","issue":{"url":"https://api.github.com/repos/dingo/api/issues/1162","repository_url":"https://api.github.com/repos/dingo/api","labels_url":"https://api.github.com/repos/dingo/api/issues/1162/labels{/name}","comments_url":"https://api.github.com/repos/dingo/api/issues/1162/comments","events_url":"https://api.github.com/repos/dingo/api/issues/1162/events","html_url":"https://github.com/dingo/api/issues/1162","id":172776382,"number":1162,"title":"Breaking Change From 5.1 -> 5.2","user":{"login":"joshuaziering","id":1530131,"avatar_url":"https://avatars.githubusercontent.com/u/1530131?v=3","gravatar_id":"","url":"https://api.github.com/users/joshuaziering","html_url":"https://github.com/joshuaziering","followers_url":"https://api.github.com/users/joshuaziering/followers","following_url":"https://api.github.com/users/joshuaziering/following{/other_user}","gists_url":"https://api.github.com/users/joshuaziering/gists{/gist_id}","starred_url":"https://api.github.com/users/joshuaziering/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshuaziering/subscriptions","organizations_url":"https://api.github.com/users/joshuaziering/orgs","repos_url":"https://api.github.com/users/joshuaziering/repos","events_url":"https://api.github.com/users/joshuaziering/events{/privacy}","received_events_url":"https://api.github.com/users/joshuaziering/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-08-23T18:46:50Z","updated_at":"2016-08-25T01:56:09Z","closed_at":null,"body":"Hello,\r\n\r\nI've scoured both the Laravel upgrade docs and dingo docs for a solution here but I can't seem to find one. On laravel 5.1.* this block of code returns an array of JSON objects:\r\n\r\n```php\r\npublic function index($account)\r\n\t{\r\n\t\tif(Auth::user()->accounts->contains($account))\r\n\t\t{\r\n\t\t\t$drones = $account->drones()->where('retired',false)->get()->sortBy('total_flight_time');\r\n\t\t\t$drones = $drones->reverse();\r\n\t\t\treturn $drones;\r\n\t\t}\r\n\t}\r\n```\r\n\r\nReturns:\r\n\r\n```\r\n{\r\n  \"drones\": [\r\n    {\r\n      \"id\": 21,\r\n      .....\r\n    },\r\n    {\r\n      \"id\": 26,\r\n      ......\r\n    }\r\n]\r\n}\r\n```\r\n\r\nHowever, when I upgrade to Laravel 5.2 I get the following unexpected result: \r\n\r\n```\r\n{\r\n  \"drones\": {\r\n    \"0\": {\r\n      \"id\": 21,\r\n       ....\r\n    },\r\n    \"2\": {\r\n      \"id\": 26,\r\n       .....\r\n    }\r\n}\r\n}\r\n```\r\n\r\nCan you point me to anywhere that might explain what's breaking this and how I can keep my API consistent while moving to 5.2? I can't afford breaking changes at the moment.\r\n\r\nThanks\r\n\r\nJosh\r\n"},"comment":{"url":"https://api.github.com/repos/dingo/api/issues/comments/242260732","html_url":"https://github.com/dingo/api/issues/1162#issuecomment-242260732","issue_url":"https://api.github.com/repos/dingo/api/issues/1162","id":242260732,"user":{"login":"hskrasek","id":787487,"avatar_url":"https://avatars.githubusercontent.com/u/787487?v=3","gravatar_id":"","url":"https://api.github.com/users/hskrasek","html_url":"https://github.com/hskrasek","followers_url":"https://api.github.com/users/hskrasek/followers","following_url":"https://api.github.com/users/hskrasek/following{/other_user}","gists_url":"https://api.github.com/users/hskrasek/gists{/gist_id}","starred_url":"https://api.github.com/users/hskrasek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hskrasek/subscriptions","organizations_url":"https://api.github.com/users/hskrasek/orgs","repos_url":"https://api.github.com/users/hskrasek/repos","events_url":"https://api.github.com/users/hskrasek/events{/privacy}","received_events_url":"https://api.github.com/users/hskrasek/received_events","type":"User","site_admin":false},"created_at":"2016-08-25T01:56:09Z","updated_at":"2016-08-25T01:56:09Z","body":"@joshuaziering This seems to be a result of a change to Laravel's collection object between L5.1 and L5.2. \r\n\r\nWhen you return a collection object by itself, Laravel will determine it can be turned into JSON and call the `toJson()"}}
{"actor":{"display_login":"hskrasek"}}