{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/15204","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/15204/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/15204/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/15204/events","html_url":"https://github.com/laravel/framework/issues/15204","id":174512052,"number":15204,"title":"withCount() on belongsToMany will include Pivot table","user":{"login":"manmohanjit1","id":7972390,"avatar_url":"https://avatars3.githubusercontent.com/u/7972390?v=4","gravatar_id":"","url":"https://api.github.com/users/manmohanjit1","html_url":"https://github.com/manmohanjit1","followers_url":"https://api.github.com/users/manmohanjit1/followers","following_url":"https://api.github.com/users/manmohanjit1/following{/other_user}","gists_url":"https://api.github.com/users/manmohanjit1/gists{/gist_id}","starred_url":"https://api.github.com/users/manmohanjit1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manmohanjit1/subscriptions","organizations_url":"https://api.github.com/users/manmohanjit1/orgs","repos_url":"https://api.github.com/users/manmohanjit1/repos","events_url":"https://api.github.com/users/manmohanjit1/events{/privacy}","received_events_url":"https://api.github.com/users/manmohanjit1/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-09-01T12:36:44Z","updated_at":"2017-11-29T11:41:38Z","closed_at":"2017-11-29T11:41:38Z","author_association":"NONE","body":"https://github.com/laravel/framework/blob/5.3/src/Illuminate/Database/Eloquent/Builder.php#L1050\n\nI'm using many-to-many relationship with belongsToMany() on both models.\n\n**TLDR:**\nwithCount vs with gives me two different results\nhttps://gist.github.com/manmohanjit1/6662ad8060c1f2b202f6798a32cd3691\n\nWhen I use withCount(['relation']), it includes relation_count and also all the Pivot table values in the same object. However when I use with(['relation']) it puts the Pivot table values in a separate variable in the object as how it's documented.\n\nIn my User model:\n\n`return $this->belongsToMany('App\\Bibliography')->withTimestamps()->withPivot('is_admin', 'can_create', 'can_update', 'can_destroy')`\n\nIs this intended behavior?\n\n`$bibs = $user->bibliographies()->withCount(['users'])->get();`\n\nvs\n\n`$bibs = $user->bibliographies()->with(['users'])->get();`\n\nhttps://gist.github.com/manmohanjit1/6662ad8060c1f2b202f6798a32cd3691\n\nI was just curious if this was an bug or is intended behavior, thanks!\n"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/347835580","html_url":"https://github.com/laravel/framework/issues/15204#issuecomment-347835580","issue_url":"https://api.github.com/repos/laravel/framework/issues/15204","id":347835580,"user":{"login":"themsaid","id":4332182,"avatar_url":"https://avatars3.githubusercontent.com/u/4332182?v=4","gravatar_id":"","url":"https://api.github.com/users/themsaid","html_url":"https://github.com/themsaid","followers_url":"https://api.github.com/users/themsaid/followers","following_url":"https://api.github.com/users/themsaid/following{/other_user}","gists_url":"https://api.github.com/users/themsaid/gists{/gist_id}","starred_url":"https://api.github.com/users/themsaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/themsaid/subscriptions","organizations_url":"https://api.github.com/users/themsaid/orgs","repos_url":"https://api.github.com/users/themsaid/repos","events_url":"https://api.github.com/users/themsaid/events{/privacy}","received_events_url":"https://api.github.com/users/themsaid/received_events","type":"User","site_admin":false},"created_at":"2017-11-29T11:41:38Z","updated_at":"2017-11-29T11:41:38Z","author_association":"MEMBER","body":"Closing for lack of activity, please report if issue still exists in 5.5"}}
{"actor":{"display_login":"themsaid"}}