{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/fels_78/pulls/comments/41217546","id":41217546,"diff_hunk":"@@ -0,0 +1,78 @@\n+<?php\n+\n+namespace FELS\\Entities\\Traits;\n+\n+use FELS\\Entities\\Relationship;\n+\n+trait FollowableTrait\n+{\n+    /**\n+     * The active relations between current user and other users.\n+     *\n+     * @return \\Illuminate\\Database\\Eloquent\\Relations\\HasMany\n+     */\n+    public function activeRelations()\n+    {\n+        return $this->hasMany(Relationship::class, 'follower_id');\n+    }\n+\n+    /**\n+     * The list of users that are followed by current user.\n+     *\n+     * @return \\Illuminate\\Database\\Eloquent\\Builder\n+     */\n+    public function following()\n+    {\n+        $ids = $this->activeRelations()->lists('followed_id')->toArray();\n+\n+        return static::whereIn('id', $ids);","path":"app/Entities/Traits/FollowableTrait.php","position":28,"original_position":28,"commit_id":"1408ab43a6cf61d97c28b59da7156d64d6df6600","original_commit_id":"1408ab43a6cf61d97c28b59da7156d64d6df6600","user":{"login":"wataridori","id":1189893,"avatar_url":"https://avatars.githubusercontent.com/u/1189893?v=3","gravatar_id":"","url":"https://api.github.com/users/wataridori","html_url":"https://github.com/wataridori","followers_url":"https://api.github.com/users/wataridori/followers","following_url":"https://api.github.com/users/wataridori/following{/other_user}","gists_url":"https://api.github.com/users/wataridori/gists{/gist_id}","starred_url":"https://api.github.com/users/wataridori/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wataridori/subscriptions","organizations_url":"https://api.github.com/users/wataridori/orgs","repos_url":"https://api.github.com/users/wataridori/repos","events_url":"https://api.github.com/users/wataridori/events{/privacy}","received_events_url":"https://api.github.com/users/wataridori/received_events","type":"User","site_admin":false},"body":"Anh vẫn không hiểu lắm viết thế này thì được lợi gì hơn so với sử dụng `belongsToMany`.\r\nTrước tiên anh chỉ thấy mặt tiêu cực của nó là em sẽ phải sử dụng 2 câu truy vấn SQL để lấy ra list following (một câu là lấy ra list `followed_id`, còn một câu là lấy ra list user nữa), trong khi đúng ra em có thể chỉ cần 1 câu SQL là được :-? ","created_at":"2015-10-06T01:14:51Z","updated_at":"2015-10-06T01:14:51Z","html_url":"https://github.com/framgia/fels_78/pull/2#discussion_r41217546","pull_request_url":"https://api.github.com/repos/framgia/fels_78/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_78/pulls/comments/41217546"},"html":{"href":"https://github.com/framgia/fels_78/pull/2#discussion_r41217546"},"pull_request":{"href":"https://api.github.com/repos/framgia/fels_78/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/fels_78/pulls/2","id":46729433,"html_url":"https://github.com/framgia/fels_78/pull/2","diff_url":"https://github.com/framgia/fels_78/pull/2.diff","patch_url":"https://github.com/framgia/fels_78/pull/2.patch","issue_url":"https://api.github.com/repos/framgia/fels_78/issues/2","number":2,"state":"open","locked":false,"title":"Initialize models and migrations.","user":{"login":"vinhnguyen-hust","id":5989866,"avatar_url":"https://avatars.githubusercontent.com/u/5989866?v=3","gravatar_id":"","url":"https://api.github.com/users/vinhnguyen-hust","html_url":"https://github.com/vinhnguyen-hust","followers_url":"https://api.github.com/users/vinhnguyen-hust/followers","following_url":"https://api.github.com/users/vinhnguyen-hust/following{/other_user}","gists_url":"https://api.github.com/users/vinhnguyen-hust/gists{/gist_id}","starred_url":"https://api.github.com/users/vinhnguyen-hust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vinhnguyen-hust/subscriptions","organizations_url":"https://api.github.com/users/vinhnguyen-hust/orgs","repos_url":"https://api.github.com/users/vinhnguyen-hust/repos","events_url":"https://api.github.com/users/vinhnguyen-hust/events{/privacy}","received_events_url":"https://api.github.com/users/vinhnguyen-hust/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-04T17:55:29Z","updated_at":"2015-10-06T01:14:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"99f1eb4c7859b1d674c9199ce0c5c94cf70a3331","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/framgia/fels_78/pulls/2/commits","review_comments_url":"https://api.github.com/repos/framgia/fels_78/pulls/2/comments","review_comment_url":"https://api.github.com/repos/framgia/fels_78/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/fels_78/issues/2/comments","statuses_url":"https://api.github.com/repos/framgia/fels_78/statuses/1408ab43a6cf61d97c28b59da7156d64d6df6600","head":{"label":"vinhnguyen-hust:init-model-migration","ref":"init-model-migration","sha":"1408ab43a6cf61d97c28b59da7156d64d6df6600","user":{"login":"vinhnguyen-hust","id":5989866,"avatar_url":"https://avatars.githubusercontent.com/u/5989866?v=3","gravatar_id":"","url":"https://api.github.com/users/vinhnguyen-hust","html_url":"https://github.com/vinhnguyen-hust","followers_url":"https://api.github.com/users/vinhnguyen-hust/followers","following_url":"https://api.github.com/users/vinhnguyen-hust/following{/other_user}","gists_url":"https://api.github.com/users/vinhnguyen-hust/gists{/gist_id}","starred_url":"https://api.github.com/users/vinhnguyen-hust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vinhnguyen-hust/subscriptions","organizations_url":"https://api.github.com/users/vinhnguyen-hust/orgs","repos_url":"https://api.github.com/users/vinhnguyen-hust/repos","events_url":"https://api.github.com/users/vinhnguyen-hust/events{/privacy}","received_events_url":"https://api.github.com/users/vinhnguyen-hust/received_events","type":"User","site_admin":false},"repo":{"id":43418772,"name":"fels_78","full_name":"vinhnguyen-hust/fels_78","owner":{"login":"vinhnguyen-hust","id":5989866,"avatar_url":"https://avatars.githubusercontent.com/u/5989866?v=3","gravatar_id":"","url":"https://api.github.com/users/vinhnguyen-hust","html_url":"https://github.com/vinhnguyen-hust","followers_url":"https://api.github.com/users/vinhnguyen-hust/followers","following_url":"https://api.github.com/users/vinhnguyen-hust/following{/other_user}","gists_url":"https://api.github.com/users/vinhnguyen-hust/gists{/gist_id}","starred_url":"https://api.github.com/users/vinhnguyen-hust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vinhnguyen-hust/subscriptions","organizations_url":"https://api.github.com/users/vinhnguyen-hust/orgs","repos_url":"https://api.github.com/users/vinhnguyen-hust/repos","events_url":"https://api.github.com/users/vinhnguyen-hust/events{/privacy}","received_events_url":"https://api.github.com/users/vinhnguyen-hust/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vinhnguyen-hust/fels_78","description":"Framgia E-Learning System (training)","fork":true,"url":"https://api.github.com/repos/vinhnguyen-hust/fels_78","forks_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/forks","keys_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/teams","hooks_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/hooks","issue_events_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/issues/events{/number}","events_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/events","assignees_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/assignees{/user}","branches_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/branches{/branch}","tags_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/tags","blobs_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/git/refs{/sha}","trees_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/statuses/{sha}","languages_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/languages","stargazers_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/stargazers","contributors_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/contributors","subscribers_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/subscribers","subscription_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/subscription","commits_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/commits{/sha}","git_commits_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/git/commits{/sha}","comments_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/comments{/number}","issue_comment_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/issues/comments{/number}","contents_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/contents/{+path}","compare_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/merges","archive_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/downloads","issues_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/issues{/number}","pulls_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/pulls{/number}","milestones_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/milestones{/number}","notifications_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/labels{/name}","releases_url":"https://api.github.com/repos/vinhnguyen-hust/fels_78/releases{/id}","created_at":"2015-09-30T07:34:45Z","updated_at":"2015-10-04T18:17:32Z","pushed_at":"2015-10-05T16:30:53Z","git_url":"git://github.com/vinhnguyen-hust/fels_78.git","ssh_url":"git@github.com:vinhnguyen-hust/fels_78.git","clone_url":"https://github.com/vinhnguyen-hust/fels_78.git","svn_url":"https://github.com/vinhnguyen-hust/fels_78","homepage":null,"size":0,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"framgia:develop","ref":"develop","sha":"9552e7da2c30a884fd371399aee06c18fa744e9d","user":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"repo":{"id":43418534,"name":"fels_78","full_name":"framgia/fels_78","owner":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/framgia/fels_78","description":"Framgia E-Learning System (training)","fork":false,"url":"https://api.github.com/repos/framgia/fels_78","forks_url":"https://api.github.com/repos/framgia/fels_78/forks","keys_url":"https://api.github.com/repos/framgia/fels_78/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/fels_78/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/fels_78/teams","hooks_url":"https://api.github.com/repos/framgia/fels_78/hooks","issue_events_url":"https://api.github.com/repos/framgia/fels_78/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/fels_78/events","assignees_url":"https://api.github.com/repos/framgia/fels_78/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/fels_78/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/fels_78/tags","blobs_url":"https://api.github.com/repos/framgia/fels_78/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/fels_78/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/fels_78/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/fels_78/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/fels_78/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/fels_78/languages","stargazers_url":"https://api.github.com/repos/framgia/fels_78/stargazers","contributors_url":"https://api.github.com/repos/framgia/fels_78/contributors","subscribers_url":"https://api.github.com/repos/framgia/fels_78/subscribers","subscription_url":"https://api.github.com/repos/framgia/fels_78/subscription","commits_url":"https://api.github.com/repos/framgia/fels_78/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/fels_78/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/fels_78/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/fels_78/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/fels_78/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/fels_78/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/fels_78/merges","archive_url":"https://api.github.com/repos/framgia/fels_78/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/fels_78/downloads","issues_url":"https://api.github.com/repos/framgia/fels_78/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/fels_78/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/fels_78/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/fels_78/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/fels_78/labels{/name}","releases_url":"https://api.github.com/repos/framgia/fels_78/releases{/id}","created_at":"2015-09-30T07:29:37Z","updated_at":"2015-09-30T07:29:37Z","pushed_at":"2015-10-05T16:30:53Z","git_url":"git://github.com/framgia/fels_78.git","ssh_url":"git@github.com:framgia/fels_78.git","clone_url":"https://github.com/framgia/fels_78.git","svn_url":"https://github.com/framgia/fels_78","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_78/pulls/2"},"html":{"href":"https://github.com/framgia/fels_78/pull/2"},"issue":{"href":"https://api.github.com/repos/framgia/fels_78/issues/2"},"comments":{"href":"https://api.github.com/repos/framgia/fels_78/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/fels_78/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/fels_78/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/fels_78/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/fels_78/statuses/1408ab43a6cf61d97c28b59da7156d64d6df6600"}}}}