{"action":"created","issue":{"url":"https://api.github.com/repos/thephpleague/fractal/issues/190","labels_url":"https://api.github.com/repos/thephpleague/fractal/issues/190/labels{/name}","comments_url":"https://api.github.com/repos/thephpleague/fractal/issues/190/comments","events_url":"https://api.github.com/repos/thephpleague/fractal/issues/190/events","html_url":"https://github.com/thephpleague/fractal/issues/190","id":89543656,"number":190,"title":"How can I eager load included when they have parameters","user":{"login":"kfirba","id":8510486,"avatar_url":"https://avatars.githubusercontent.com/u/8510486?v=3","gravatar_id":"","url":"https://api.github.com/users/kfirba","html_url":"https://github.com/kfirba","followers_url":"https://api.github.com/users/kfirba/followers","following_url":"https://api.github.com/users/kfirba/following{/other_user}","gists_url":"https://api.github.com/users/kfirba/gists{/gist_id}","starred_url":"https://api.github.com/users/kfirba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kfirba/subscriptions","organizations_url":"https://api.github.com/users/kfirba/orgs","repos_url":"https://api.github.com/users/kfirba/repos","events_url":"https://api.github.com/users/kfirba/events{/privacy}","received_events_url":"https://api.github.com/users/kfirba/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-06-19T11:42:53Z","updated_at":"2015-06-22T10:29:06Z","closed_at":null,"body":"Hello.\r\n\r\nI'm using fractal to build some API. I love the way is simplifies the process. \r\nSince there are many relations which I can load with the API, I would love to use eager loading so I won't query my DB way too many times. For that, I need to parse the `included` parameter.\r\n\r\nHowever, what happens when the `include` has some parameters? maybe something like:\r\n```\r\napi.example.com/v1/posts?include=comments:take(10):order(created_at|desc)\r\n```\r\n\r\nCurrently I have a `ApiController`:\r\n\r\n```\r\n    /**\r\n     * @param Request $request\r\n     */\r\n    public function __construct(Request $request)\r\n    {\r\n        $this->request = $request;\r\n\r\n        if ($request->has('include')) {\r\n            $this->fractal()->parseIncludes($request->get('include'));\r\n        }\r\n\r\n        $this->registerMiddlewares();\r\n    }\r\n```\r\n\r\nNow it will tell fractal to load the wanted relationships, however, I can't just go ahead and include the relationship anywhere else in my app since I have to parse the `include` parameter now and apply any constraint that the user passed. \r\n\r\nHow can I eager load that? As it stands, the Manager class will parse the `include` parameter and give me an access to the parsed `include` only when I'm **including** the relationship which means it's too late to eager load the relationship.\r\n\r\nAny idea?"},"comment":{"url":"https://api.github.com/repos/thephpleague/fractal/issues/comments/114060137","html_url":"https://github.com/thephpleague/fractal/issues/190#issuecomment-114060137","issue_url":"https://api.github.com/repos/thephpleague/fractal/issues/190","id":114060137,"user":{"login":"brayniverse","id":945367,"avatar_url":"https://avatars.githubusercontent.com/u/945367?v=3","gravatar_id":"","url":"https://api.github.com/users/brayniverse","html_url":"https://github.com/brayniverse","followers_url":"https://api.github.com/users/brayniverse/followers","following_url":"https://api.github.com/users/brayniverse/following{/other_user}","gists_url":"https://api.github.com/users/brayniverse/gists{/gist_id}","starred_url":"https://api.github.com/users/brayniverse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brayniverse/subscriptions","organizations_url":"https://api.github.com/users/brayniverse/orgs","repos_url":"https://api.github.com/users/brayniverse/repos","events_url":"https://api.github.com/users/brayniverse/events{/privacy}","received_events_url":"https://api.github.com/users/brayniverse/received_events","type":"User","site_admin":false},"created_at":"2015-06-22T10:29:06Z","updated_at":"2015-06-22T10:29:06Z","body":":+1: Hopefully it helps you."}}