{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/ffn_04/pulls/comments/74562504","id":74562504,"diff_hunk":"@@ -48,4 +54,97 @@ public function delete($ids)\n             return ['error' => $ex->getMessage()];\n         }\n     }\n+\n+    public function rank($leagueId)\n+    {\n+        try {\n+            $lastSeason = LeagueMatch::where('league_id', $leagueId)->orderBy('season_id', 'DESC')->first();\n+\n+            if (!count($lastSeason)) {\n+                return ['error' => trans('message.season_data_is_empty')];\n+            }\n+\n+            $rank['teams'] = Rank::where('season_id', $lastSeason['season_id'])->orderBy('score', 'DESC')->get();\n+\n+            if (!count($rank['teams'])) {\n+                return ['error' => trans('message.rank_data_is_empty')];\n+            }\n+\n+            $rank['league'] = League::find($lastSeason['league_id']);\n+            $rank['season'] = Season::find($lastSeason['season_id']);\n+            $teamIds = $rank['teams']->lists('team_id');\n+            $teams = Team::whereIn('id', $teamIds)->get();\n+            foreach ($teams as $key => $team) {\n+                $rank['teams'][$key]['team'] = $team['name'];\n+            }\n+\n+            return $rank;\n+        } catch (Exception $ex) {\n+            return ['error' => $ex->getMessage()];\n+        }\n+    }\n+\n+    public function schedule($leagueId)\n+    {\n+        try {\n+            $lastSeason = LeagueMatch::where('league_id', $leagueId)->orderBy('season_id', 'DESC')->first();\n+\n+            if (!count($lastSeason)) {\n+                return ['error' => trans('message.season_data_is_empty')];\n+            }\n+\n+            $matchIds = LeagueMatch::where('season_id', $lastSeason['season_id'])->lists('match_id');\n+            $matches = Match::whereIn('id', $matchIds)->where('start_time', '>', Carbon::now()->toDateString())\n+                ->orderBy('start_time', 'ASC')->get();\n+            $matches = $this->getTeams($matches);\n+            $schedule['matches'] = $this->splitMatches($matches);\n+            $schedule['league'] = League::find($leagueId);\n+            $schedule['season'] = Season::find($lastSeason['season_id']);\n+\n+            return $schedule;\n+        } catch (Exception $ex) {\n+            return ['error' => $ex->getMessage()];\n+        }\n+    }\n+\n+    public function getTeams($matches)\n+    {\n+        $teamIDs = [];","path":"app/Repositories/League/LeagueRepository.php","position":78,"original_position":78,"commit_id":"1a40914eebd3d5635c71ec2d140fdf4747544f01","original_commit_id":"1a40914eebd3d5635c71ec2d140fdf4747544f01","user":{"login":"hungcoj","id":5018043,"avatar_url":"https://avatars.githubusercontent.com/u/5018043?v=3","gravatar_id":"","url":"https://api.github.com/users/hungcoj","html_url":"https://github.com/hungcoj","followers_url":"https://api.github.com/users/hungcoj/followers","following_url":"https://api.github.com/users/hungcoj/following{/other_user}","gists_url":"https://api.github.com/users/hungcoj/gists{/gist_id}","starred_url":"https://api.github.com/users/hungcoj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hungcoj/subscriptions","organizations_url":"https://api.github.com/users/hungcoj/orgs","repos_url":"https://api.github.com/users/hungcoj/repos","events_url":"https://api.github.com/users/hungcoj/events{/privacy}","received_events_url":"https://api.github.com/users/hungcoj/received_events","type":"User","site_admin":false},"body":"Đặt tên thế này ạ, soi mãi dc cái lỗi (2tat)","created_at":"2016-08-12T09:17:30Z","updated_at":"2016-08-12T09:17:30Z","html_url":"https://github.com/framgia/ffn_04/pull/28#discussion_r74562504","pull_request_url":"https://api.github.com/repos/framgia/ffn_04/pulls/28","_links":{"self":{"href":"https://api.github.com/repos/framgia/ffn_04/pulls/comments/74562504"},"html":{"href":"https://github.com/framgia/ffn_04/pull/28#discussion_r74562504"},"pull_request":{"href":"https://api.github.com/repos/framgia/ffn_04/pulls/28"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/ffn_04/pulls/28","id":81083339,"html_url":"https://github.com/framgia/ffn_04/pull/28","diff_url":"https://github.com/framgia/ffn_04/pull/28.diff","patch_url":"https://github.com/framgia/ffn_04/pull/28.patch","issue_url":"https://api.github.com/repos/framgia/ffn_04/issues/28","number":28,"state":"open","locked":false,"title":"view rank, schedule table","user":{"login":"luongs3","id":12150725,"avatar_url":"https://avatars.githubusercontent.com/u/12150725?v=3","gravatar_id":"","url":"https://api.github.com/users/luongs3","html_url":"https://github.com/luongs3","followers_url":"https://api.github.com/users/luongs3/followers","following_url":"https://api.github.com/users/luongs3/following{/other_user}","gists_url":"https://api.github.com/users/luongs3/gists{/gist_id}","starred_url":"https://api.github.com/users/luongs3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luongs3/subscriptions","organizations_url":"https://api.github.com/users/luongs3/orgs","repos_url":"https://api.github.com/users/luongs3/repos","events_url":"https://api.github.com/users/luongs3/events{/privacy}","received_events_url":"https://api.github.com/users/luongs3/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-12T08:25:16Z","updated_at":"2016-08-12T09:17:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ceb978a6e30d8d0855c5ebfc7331d57a7dc25b71","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/framgia/ffn_04/pulls/28/commits","review_comments_url":"https://api.github.com/repos/framgia/ffn_04/pulls/28/comments","review_comment_url":"https://api.github.com/repos/framgia/ffn_04/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/ffn_04/issues/28/comments","statuses_url":"https://api.github.com/repos/framgia/ffn_04/statuses/1a40914eebd3d5635c71ec2d140fdf4747544f01","head":{"label":"luongs3:view_rank","ref":"view_rank","sha":"1a40914eebd3d5635c71ec2d140fdf4747544f01","user":{"login":"luongs3","id":12150725,"avatar_url":"https://avatars.githubusercontent.com/u/12150725?v=3","gravatar_id":"","url":"https://api.github.com/users/luongs3","html_url":"https://github.com/luongs3","followers_url":"https://api.github.com/users/luongs3/followers","following_url":"https://api.github.com/users/luongs3/following{/other_user}","gists_url":"https://api.github.com/users/luongs3/gists{/gist_id}","starred_url":"https://api.github.com/users/luongs3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luongs3/subscriptions","organizations_url":"https://api.github.com/users/luongs3/orgs","repos_url":"https://api.github.com/users/luongs3/repos","events_url":"https://api.github.com/users/luongs3/events{/privacy}","received_events_url":"https://api.github.com/users/luongs3/received_events","type":"User","site_admin":false},"repo":{"id":64116231,"name":"ffn_04","full_name":"luongs3/ffn_04","owner":{"login":"luongs3","id":12150725,"avatar_url":"https://avatars.githubusercontent.com/u/12150725?v=3","gravatar_id":"","url":"https://api.github.com/users/luongs3","html_url":"https://github.com/luongs3","followers_url":"https://api.github.com/users/luongs3/followers","following_url":"https://api.github.com/users/luongs3/following{/other_user}","gists_url":"https://api.github.com/users/luongs3/gists{/gist_id}","starred_url":"https://api.github.com/users/luongs3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luongs3/subscriptions","organizations_url":"https://api.github.com/users/luongs3/orgs","repos_url":"https://api.github.com/users/luongs3/repos","events_url":"https://api.github.com/users/luongs3/events{/privacy}","received_events_url":"https://api.github.com/users/luongs3/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/luongs3/ffn_04","description":"Framgia Football News (training)","fork":true,"url":"https://api.github.com/repos/luongs3/ffn_04","forks_url":"https://api.github.com/repos/luongs3/ffn_04/forks","keys_url":"https://api.github.com/repos/luongs3/ffn_04/keys{/key_id}","collaborators_url":"https://api.github.com/repos/luongs3/ffn_04/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/luongs3/ffn_04/teams","hooks_url":"https://api.github.com/repos/luongs3/ffn_04/hooks","issue_events_url":"https://api.github.com/repos/luongs3/ffn_04/issues/events{/number}","events_url":"https://api.github.com/repos/luongs3/ffn_04/events","assignees_url":"https://api.github.com/repos/luongs3/ffn_04/assignees{/user}","branches_url":"https://api.github.com/repos/luongs3/ffn_04/branches{/branch}","tags_url":"https://api.github.com/repos/luongs3/ffn_04/tags","blobs_url":"https://api.github.com/repos/luongs3/ffn_04/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/luongs3/ffn_04/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/luongs3/ffn_04/git/refs{/sha}","trees_url":"https://api.github.com/repos/luongs3/ffn_04/git/trees{/sha}","statuses_url":"https://api.github.com/repos/luongs3/ffn_04/statuses/{sha}","languages_url":"https://api.github.com/repos/luongs3/ffn_04/languages","stargazers_url":"https://api.github.com/repos/luongs3/ffn_04/stargazers","contributors_url":"https://api.github.com/repos/luongs3/ffn_04/contributors","subscribers_url":"https://api.github.com/repos/luongs3/ffn_04/subscribers","subscription_url":"https://api.github.com/repos/luongs3/ffn_04/subscription","commits_url":"https://api.github.com/repos/luongs3/ffn_04/commits{/sha}","git_commits_url":"https://api.github.com/repos/luongs3/ffn_04/git/commits{/sha}","comments_url":"https://api.github.com/repos/luongs3/ffn_04/comments{/number}","issue_comment_url":"https://api.github.com/repos/luongs3/ffn_04/issues/comments{/number}","contents_url":"https://api.github.com/repos/luongs3/ffn_04/contents/{+path}","compare_url":"https://api.github.com/repos/luongs3/ffn_04/compare/{base}...{head}","merges_url":"https://api.github.com/repos/luongs3/ffn_04/merges","archive_url":"https://api.github.com/repos/luongs3/ffn_04/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/luongs3/ffn_04/downloads","issues_url":"https://api.github.com/repos/luongs3/ffn_04/issues{/number}","pulls_url":"https://api.github.com/repos/luongs3/ffn_04/pulls{/number}","milestones_url":"https://api.github.com/repos/luongs3/ffn_04/milestones{/number}","notifications_url":"https://api.github.com/repos/luongs3/ffn_04/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/luongs3/ffn_04/labels{/name}","releases_url":"https://api.github.com/repos/luongs3/ffn_04/releases{/id}","deployments_url":"https://api.github.com/repos/luongs3/ffn_04/deployments","created_at":"2016-07-25T08:13:42Z","updated_at":"2016-07-25T04:15:22Z","pushed_at":"2016-08-12T08:31:29Z","git_url":"git://github.com/luongs3/ffn_04.git","ssh_url":"git@github.com:luongs3/ffn_04.git","clone_url":"https://github.com/luongs3/ffn_04.git","svn_url":"https://github.com/luongs3/ffn_04","homepage":null,"size":1529,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"framgia:develop","ref":"develop","sha":"9760ac78d439cf91ad25134651e50a41efc702f5","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":64103106,"name":"ffn_04","full_name":"framgia/ffn_04","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/ffn_04","description":"Framgia Football News (training)","fork":false,"url":"https://api.github.com/repos/framgia/ffn_04","forks_url":"https://api.github.com/repos/framgia/ffn_04/forks","keys_url":"https://api.github.com/repos/framgia/ffn_04/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/ffn_04/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/ffn_04/teams","hooks_url":"https://api.github.com/repos/framgia/ffn_04/hooks","issue_events_url":"https://api.github.com/repos/framgia/ffn_04/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/ffn_04/events","assignees_url":"https://api.github.com/repos/framgia/ffn_04/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/ffn_04/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/ffn_04/tags","blobs_url":"https://api.github.com/repos/framgia/ffn_04/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/ffn_04/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/ffn_04/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/ffn_04/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/ffn_04/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/ffn_04/languages","stargazers_url":"https://api.github.com/repos/framgia/ffn_04/stargazers","contributors_url":"https://api.github.com/repos/framgia/ffn_04/contributors","subscribers_url":"https://api.github.com/repos/framgia/ffn_04/subscribers","subscription_url":"https://api.github.com/repos/framgia/ffn_04/subscription","commits_url":"https://api.github.com/repos/framgia/ffn_04/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/ffn_04/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/ffn_04/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/ffn_04/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/ffn_04/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/ffn_04/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/ffn_04/merges","archive_url":"https://api.github.com/repos/framgia/ffn_04/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/ffn_04/downloads","issues_url":"https://api.github.com/repos/framgia/ffn_04/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/ffn_04/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/ffn_04/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/ffn_04/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/ffn_04/labels{/name}","releases_url":"https://api.github.com/repos/framgia/ffn_04/releases{/id}","deployments_url":"https://api.github.com/repos/framgia/ffn_04/deployments","created_at":"2016-07-25T04:15:22Z","updated_at":"2016-08-08T02:02:07Z","pushed_at":"2016-08-12T08:31:30Z","git_url":"git://github.com/framgia/ffn_04.git","ssh_url":"git@github.com:framgia/ffn_04.git","clone_url":"https://github.com/framgia/ffn_04.git","svn_url":"https://github.com/framgia/ffn_04","homepage":null,"size":1621,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":2,"forks":5,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/ffn_04/pulls/28"},"html":{"href":"https://github.com/framgia/ffn_04/pull/28"},"issue":{"href":"https://api.github.com/repos/framgia/ffn_04/issues/28"},"comments":{"href":"https://api.github.com/repos/framgia/ffn_04/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/ffn_04/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/ffn_04/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/ffn_04/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/ffn_04/statuses/1a40914eebd3d5635c71ec2d140fdf4747544f01"}}}}
{"actor":{"display_login":"hungcoj"}}