{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/tms_58/pulls/comments/68344384","id":68344384,"diff_hunk":"@@ -0,0 +1,129 @@\n+<?php\n+/**\n+ * Created by PhpStorm.\n+ * User: luongs3\n+ * Date: 1/30/2016\n+ * Time: 10:38 AM\n+ */\n+\n+namespace App\\Repositories;\n+\n+use Exception;\n+use DB;\n+\n+abstract class BaseRepository\n+{\n+\n+    protected $model;\n+\n+    public function index($subject, $options = [])\n+    {\n+        $limit = isset($options['limit']) ? $options['limit'] : config('common.base_repository.limit');\n+        $order = isset($options['order']) ? $options['order'] : config('common.base_repository.order_by');\n+        $filter = isset($options['filter']) ? $options['filter'] : config('common.base_repository.filter');\n+\n+        try {\n+            $data['rows'] = $this->model->where($filter)->orderBy($order['key'], $order['aspect'])->paginate($limit);\n+\n+            if (count($data['rows']) === 0) {\n+                throw new Exception(trans('general/message.item_not_exist'));\n+            }\n+\n+            $data['subject'] = $subject;\n+            $data['buttons'] = isset($options['buttons']) ? $options['buttons'] : config('common.base_repository.buttons');\n+            $data['columns'] = isset($options['columns']) ? $options['columns'] : $this->model->getFillable();\n+            $data['alerts'] = config('common.base_repository.alerts');\n+            $data['ids'] = [];\n+            foreach ($data['rows'] as $key => $row) {\n+                $data['ids'][$key] = $row['id'];\n+                $data['rows'][$key] = $row->where('id', $row['id'])->first($data['columns']);\n+            }\n+\n+            return $data;\n+        } catch (Exception $e) {\n+            throw $e;","path":"app/Repositories/BaseRepository.php","position":44,"original_position":44,"commit_id":"3790cf0d7b6500546a296c181801cd80583a2cd9","original_commit_id":"8efcf84798ef6f67e0eb54575035013da387dbdd","user":{"login":"nguyenthanhtung88","id":11342207,"avatar_url":"https://avatars.githubusercontent.com/u/11342207?v=3","gravatar_id":"","url":"https://api.github.com/users/nguyenthanhtung88","html_url":"https://github.com/nguyenthanhtung88","followers_url":"https://api.github.com/users/nguyenthanhtung88/followers","following_url":"https://api.github.com/users/nguyenthanhtung88/following{/other_user}","gists_url":"https://api.github.com/users/nguyenthanhtung88/gists{/gist_id}","starred_url":"https://api.github.com/users/nguyenthanhtung88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguyenthanhtung88/subscriptions","organizations_url":"https://api.github.com/users/nguyenthanhtung88/orgs","repos_url":"https://api.github.com/users/nguyenthanhtung88/repos","events_url":"https://api.github.com/users/nguyenthanhtung88/events{/privacy}","received_events_url":"https://api.github.com/users/nguyenthanhtung88/received_events","type":"User","site_admin":false},"body":"@luongs3 : Em có thấy xử lý như vậy bị trùng lặp không? Ở Controller em đã có try ... catch để bắt exception rồi, đoạn xử lý save của em chẳng hạn ở trong Repository nó cũng sẽ nằm trong đoạn try ... catch của Controller, có exception thì ở Controller cũng nhận được.\r\n-> Vậy thì tại sao lại phải try ... catch ở Repository, bắn ra exception, rồi Controller lại phải try ... catch 1 lần nữa để hứng? Tại sao không chỉ thực hiện try ... catch ở Controller thôi.","created_at":"2016-06-24T01:59:29Z","updated_at":"2016-06-24T01:59:29Z","html_url":"https://github.com/framgia/tms_58/pull/3#discussion_r68344384","pull_request_url":"https://api.github.com/repos/framgia/tms_58/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/framgia/tms_58/pulls/comments/68344384"},"html":{"href":"https://github.com/framgia/tms_58/pull/3#discussion_r68344384"},"pull_request":{"href":"https://api.github.com/repos/framgia/tms_58/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/tms_58/pulls/3","id":74813737,"html_url":"https://github.com/framgia/tms_58/pull/3","diff_url":"https://github.com/framgia/tms_58/pull/3.diff","patch_url":"https://github.com/framgia/tms_58/pull/3.patch","issue_url":"https://api.github.com/repos/framgia/tms_58/issues/3","number":3,"state":"open","locked":false,"title":"suppervisor profile","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":"- Redmine: \r\n + https://dev.framgia.com/redmine/issues/66218\r\n + https://dev.framgia.com/redmine/issues/66220\r\n- Feature: Supervisor profile\r\n  + Show supervisor profile\r\n  + Edit supervisor profile\r\n  + Make BaseRepository, layout for view\r\n- Image: để pr sau có các file js, css, bootstrap em sẽ post giao diện sau. em thấy hơi nhiều rồi nên em để mấy file đấy cho pull sau.","created_at":"2016-06-22T16:17:10Z","updated_at":"2016-06-24T01:59:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ef6bfcad94b8767ca9a6f59238cbd42d8f321aa6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/framgia/tms_58/pulls/3/commits","review_comments_url":"https://api.github.com/repos/framgia/tms_58/pulls/3/comments","review_comment_url":"https://api.github.com/repos/framgia/tms_58/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/tms_58/issues/3/comments","statuses_url":"https://api.github.com/repos/framgia/tms_58/statuses/3790cf0d7b6500546a296c181801cd80583a2cd9","head":{"label":"luongs3:suppervisor_profile","ref":"suppervisor_profile","sha":"3790cf0d7b6500546a296c181801cd80583a2cd9","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":61678472,"name":"tms_58","full_name":"luongs3/tms_58","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/tms_58","description":"Framgia Training System (training)","fork":true,"url":"https://api.github.com/repos/luongs3/tms_58","forks_url":"https://api.github.com/repos/luongs3/tms_58/forks","keys_url":"https://api.github.com/repos/luongs3/tms_58/keys{/key_id}","collaborators_url":"https://api.github.com/repos/luongs3/tms_58/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/luongs3/tms_58/teams","hooks_url":"https://api.github.com/repos/luongs3/tms_58/hooks","issue_events_url":"https://api.github.com/repos/luongs3/tms_58/issues/events{/number}","events_url":"https://api.github.com/repos/luongs3/tms_58/events","assignees_url":"https://api.github.com/repos/luongs3/tms_58/assignees{/user}","branches_url":"https://api.github.com/repos/luongs3/tms_58/branches{/branch}","tags_url":"https://api.github.com/repos/luongs3/tms_58/tags","blobs_url":"https://api.github.com/repos/luongs3/tms_58/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/luongs3/tms_58/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/luongs3/tms_58/git/refs{/sha}","trees_url":"https://api.github.com/repos/luongs3/tms_58/git/trees{/sha}","statuses_url":"https://api.github.com/repos/luongs3/tms_58/statuses/{sha}","languages_url":"https://api.github.com/repos/luongs3/tms_58/languages","stargazers_url":"https://api.github.com/repos/luongs3/tms_58/stargazers","contributors_url":"https://api.github.com/repos/luongs3/tms_58/contributors","subscribers_url":"https://api.github.com/repos/luongs3/tms_58/subscribers","subscription_url":"https://api.github.com/repos/luongs3/tms_58/subscription","commits_url":"https://api.github.com/repos/luongs3/tms_58/commits{/sha}","git_commits_url":"https://api.github.com/repos/luongs3/tms_58/git/commits{/sha}","comments_url":"https://api.github.com/repos/luongs3/tms_58/comments{/number}","issue_comment_url":"https://api.github.com/repos/luongs3/tms_58/issues/comments{/number}","contents_url":"https://api.github.com/repos/luongs3/tms_58/contents/{+path}","compare_url":"https://api.github.com/repos/luongs3/tms_58/compare/{base}...{head}","merges_url":"https://api.github.com/repos/luongs3/tms_58/merges","archive_url":"https://api.github.com/repos/luongs3/tms_58/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/luongs3/tms_58/downloads","issues_url":"https://api.github.com/repos/luongs3/tms_58/issues{/number}","pulls_url":"https://api.github.com/repos/luongs3/tms_58/pulls{/number}","milestones_url":"https://api.github.com/repos/luongs3/tms_58/milestones{/number}","notifications_url":"https://api.github.com/repos/luongs3/tms_58/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/luongs3/tms_58/labels{/name}","releases_url":"https://api.github.com/repos/luongs3/tms_58/releases{/id}","deployments_url":"https://api.github.com/repos/luongs3/tms_58/deployments","created_at":"2016-06-22T01:14:58Z","updated_at":"2016-06-20T02:34:04Z","pushed_at":"2016-06-24T01:27:31Z","git_url":"git://github.com/luongs3/tms_58.git","ssh_url":"git@github.com:luongs3/tms_58.git","clone_url":"https://github.com/luongs3/tms_58.git","svn_url":"https://github.com/luongs3/tms_58","homepage":null,"size":59,"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":"3048f2192e514bd799a18ad66c13003d3c47e259","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":61511639,"name":"tms_58","full_name":"framgia/tms_58","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/tms_58","description":"Framgia Training System (training)","fork":false,"url":"https://api.github.com/repos/framgia/tms_58","forks_url":"https://api.github.com/repos/framgia/tms_58/forks","keys_url":"https://api.github.com/repos/framgia/tms_58/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/tms_58/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/tms_58/teams","hooks_url":"https://api.github.com/repos/framgia/tms_58/hooks","issue_events_url":"https://api.github.com/repos/framgia/tms_58/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/tms_58/events","assignees_url":"https://api.github.com/repos/framgia/tms_58/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/tms_58/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/tms_58/tags","blobs_url":"https://api.github.com/repos/framgia/tms_58/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/tms_58/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/tms_58/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/tms_58/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/tms_58/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/tms_58/languages","stargazers_url":"https://api.github.com/repos/framgia/tms_58/stargazers","contributors_url":"https://api.github.com/repos/framgia/tms_58/contributors","subscribers_url":"https://api.github.com/repos/framgia/tms_58/subscribers","subscription_url":"https://api.github.com/repos/framgia/tms_58/subscription","commits_url":"https://api.github.com/repos/framgia/tms_58/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/tms_58/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/tms_58/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/tms_58/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/tms_58/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/tms_58/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/tms_58/merges","archive_url":"https://api.github.com/repos/framgia/tms_58/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/tms_58/downloads","issues_url":"https://api.github.com/repos/framgia/tms_58/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/tms_58/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/tms_58/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/tms_58/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/tms_58/labels{/name}","releases_url":"https://api.github.com/repos/framgia/tms_58/releases{/id}","deployments_url":"https://api.github.com/repos/framgia/tms_58/deployments","created_at":"2016-06-20T02:34:04Z","updated_at":"2016-06-20T02:34:04Z","pushed_at":"2016-06-24T01:27:32Z","git_url":"git://github.com/framgia/tms_58.git","ssh_url":"git@github.com:framgia/tms_58.git","clone_url":"https://github.com/framgia/tms_58.git","svn_url":"https://github.com/framgia/tms_58","homepage":null,"size":50,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/tms_58/pulls/3"},"html":{"href":"https://github.com/framgia/tms_58/pull/3"},"issue":{"href":"https://api.github.com/repos/framgia/tms_58/issues/3"},"comments":{"href":"https://api.github.com/repos/framgia/tms_58/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/tms_58/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/tms_58/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/tms_58/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/tms_58/statuses/3790cf0d7b6500546a296c181801cd80583a2cd9"}}}}
{"actor":{"display_login":"nguyenthanhtung88"}}