{"action":"created","issue":{"url":"https://api.github.com/repos/spatie/laravel-fractal/issues/53","repository_url":"https://api.github.com/repos/spatie/laravel-fractal","labels_url":"https://api.github.com/repos/spatie/laravel-fractal/issues/53/labels{/name}","comments_url":"https://api.github.com/repos/spatie/laravel-fractal/issues/53/comments","events_url":"https://api.github.com/repos/spatie/laravel-fractal/issues/53/events","html_url":"https://github.com/spatie/laravel-fractal/issues/53","id":190192599,"number":53,"title":"Duplicate queries?","user":{"login":"brandc87","id":11300674,"avatar_url":"https://avatars.githubusercontent.com/u/11300674?v=3","gravatar_id":"","url":"https://api.github.com/users/brandc87","html_url":"https://github.com/brandc87","followers_url":"https://api.github.com/users/brandc87/followers","following_url":"https://api.github.com/users/brandc87/following{/other_user}","gists_url":"https://api.github.com/users/brandc87/gists{/gist_id}","starred_url":"https://api.github.com/users/brandc87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brandc87/subscriptions","organizations_url":"https://api.github.com/users/brandc87/orgs","repos_url":"https://api.github.com/users/brandc87/repos","events_url":"https://api.github.com/users/brandc87/events{/privacy}","received_events_url":"https://api.github.com/users/brandc87/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-17T23:14:59Z","updated_at":"2016-11-18T05:19:10Z","closed_at":"2016-11-18T05:19:10Z","body":"Hi, unsure if the error is with my code. It seems using include runs a query twice?\r\n\r\nHere I'm including a series.\r\n```\r\n    public function includeSeries(Set $set)\r\n    {\r\n        $series = $set->series()->withCount('sets')->first();\r\n\r\n        return $this->item($series, new SeriesTransformer);\r\n    }\r\n```\r\n\r\nThis is the series transformer:\r\n```\r\n    public function transform(Series $series)\r\n    {\r\n        return [\r\n            'series_name' => $series->name,\r\n            'set_count' => $series->sets_count\r\n        ];\r\n    }\r\n```\r\n\r\nAll put together with this for the time being:\r\n```\r\n        $sets = Set::all();\r\n\r\n        response()->json(fractal()\r\n            ->collection($sets, new SetTransformer())\r\n            ->includeSeries()\r\n            ->toArray(), 200);\r\n```\r\n\r\nThe duplicate query I'm getting is:\r\n`select *, (select count(*) from `sets` where `sets`.`series_id` = `series`.`id`) as `sets_count` from `series` where `series`.`id` = '1' limit 1`\r\n\r\nIf i remove the include this isn't being called at all anymore."},"comment":{"url":"https://api.github.com/repos/spatie/laravel-fractal/issues/comments/261451055","html_url":"https://github.com/spatie/laravel-fractal/issues/53#issuecomment-261451055","issue_url":"https://api.github.com/repos/spatie/laravel-fractal/issues/53","id":261451055,"user":{"login":"freekmurze","id":483853,"avatar_url":"https://avatars.githubusercontent.com/u/483853?v=3","gravatar_id":"","url":"https://api.github.com/users/freekmurze","html_url":"https://github.com/freekmurze","followers_url":"https://api.github.com/users/freekmurze/followers","following_url":"https://api.github.com/users/freekmurze/following{/other_user}","gists_url":"https://api.github.com/users/freekmurze/gists{/gist_id}","starred_url":"https://api.github.com/users/freekmurze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freekmurze/subscriptions","organizations_url":"https://api.github.com/users/freekmurze/orgs","repos_url":"https://api.github.com/users/freekmurze/repos","events_url":"https://api.github.com/users/freekmurze/events{/privacy}","received_events_url":"https://api.github.com/users/freekmurze/received_events","type":"User","site_admin":false},"created_at":"2016-11-18T05:19:10Z","updated_at":"2016-11-18T05:19:10Z","body":"This package doesn't do anything regarding querying the database, so this issue is caused by something in your own project."}}
{"actor":{"display_login":"freekmurze"}}