{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/fels_186/pulls/comments/80213838","id":80213838,"diff_hunk":"@@ -0,0 +1,147 @@\n+<?php\n+namespace App\\Repositories\\Eloquent;\n+\n+use App\\Repositories\\Contracts\\RepositoryInterface;\n+use Illuminate\\Database\\Eloquent\\Model;\n+use Illuminate\\Container\\Container as App;\n+\n+abstract class BaseRepository implements RepositoryInterface\n+{\n+\n+    private $app;\n+    protected $model;\n+    \n+    public function __construct(App $app)\n+    {\n+        $this->app = $app;\n+        $this->makeModel();\n+    }\n+\n+    abstract function model();\n+    \n+    public function makeModel()\n+    {\n+        $model = $this->app->make($this->model());\n+        \n+        if (!$model instanceof Model) {\n+            throw new \\Exception(\"Class {$this->model()} must be an instance of Illuminate\\\\Database\\\\Eloquent\\\\Model\");\n+        }\n+        \n+        return $this->model = $model;\n+    }\n+    \n+    public function count()\n+    {\n+        return $this->model->count();\n+    }\n+    \n+    public function all($columns = array('*'))\n+    {\n+        return $this->model->get($columns);\n+    }\n+    \n+    public function paginate($perPage = 1, $columns = array('*'))\n+    {\n+        return $this->model->paginate($perPage, $columns);\n+    }\n+    \n+    public function lists($field, $key = null)\n+    {\n+        return $this->model->lists($field, $key);\n+    }\n+    \n+    public function create(array $data)\n+    {\n+        return $this->model->create($data);\n+    }\n+    \n+    public function insert(array $data)\n+    {\n+        return $this->model->insert($data);\n+    }\n+    \n+    public function update(array $data, $id, $attribute = 'id', $withSoftDeletes = false)\n+    {\n+        return $this->model->where($attribute, $id)->update($data);\n+    }\n+    \n+    public function delete($id)\n+    {\n+        return $this->model->destroy($id);\n+    }\n+    \n+    public function find($id, $columns = array('*'))\n+    {\n+        return $this->model->find($id, $columns);\n+    }\n+    \n+    public function findBy($field, $value, $columns = array('*'))\n+    {\n+        return $this->model->where($field, $value)->first($columns);\n+    }\n+    \n+    public function findAllBy($field, $value, $columns = array('*'))\n+    {\n+        return $this->model->where($field, $value)->get($columns);\n+    }\n+    \n+    public function search($field, $value, $columns = array('*'))\n+    {\n+        return $this->model->where($field, 'LIKE',\"%$value%\")->get($columns);\n+    }\n+    \n+    public function where($conditions, $operator = null, $value = null)","path":"app/Repositories/Eloquent/BaseRepository.php","position":93,"original_position":93,"commit_id":"4e737d6df59b4499d1ee9e8025e2000fab37fb4d","original_commit_id":"4e737d6df59b4499d1ee9e8025e2000fab37fb4d","user":{"login":"huynguyenframgia","id":13343536,"avatar_url":"https://avatars.githubusercontent.com/u/13343536?v=3","gravatar_id":"","url":"https://api.github.com/users/huynguyenframgia","html_url":"https://github.com/huynguyenframgia","followers_url":"https://api.github.com/users/huynguyenframgia/followers","following_url":"https://api.github.com/users/huynguyenframgia/following{/other_user}","gists_url":"https://api.github.com/users/huynguyenframgia/gists{/gist_id}","starred_url":"https://api.github.com/users/huynguyenframgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huynguyenframgia/subscriptions","organizations_url":"https://api.github.com/users/huynguyenframgia/orgs","repos_url":"https://api.github.com/users/huynguyenframgia/repos","events_url":"https://api.github.com/users/huynguyenframgia/events{/privacy}","received_events_url":"https://api.github.com/users/huynguyenframgia/received_events","type":"User","site_admin":false},"body":"Làm như vậy khi dùng where chỉ dùng được 1 lần và không kết hợp với thằng khác đc.\r\nVí dụ a muốn khi sử dụng where sẽ như thế này\r\n```php\r\n$userRepository->where('role', 'admin')->where('email', 'LIKE', 'test')->orWhere(....)->all()\r\n```","created_at":"2016-09-23T09:48:57Z","updated_at":"2016-09-23T09:48:57Z","html_url":"https://github.com/framgia/fels_186/pull/8#discussion_r80213838","pull_request_url":"https://api.github.com/repos/framgia/fels_186/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_186/pulls/comments/80213838"},"html":{"href":"https://github.com/framgia/fels_186/pull/8#discussion_r80213838"},"pull_request":{"href":"https://api.github.com/repos/framgia/fels_186/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/fels_186/pulls/8","id":86448695,"html_url":"https://github.com/framgia/fels_186/pull/8","diff_url":"https://github.com/framgia/fels_186/pull/8.diff","patch_url":"https://github.com/framgia/fels_186/pull/8.patch","issue_url":"https://api.github.com/repos/framgia/fels_186/issues/8","number":8,"state":"open","locked":false,"title":"Add repositories","user":{"login":"quanvhframgia","id":22186721,"avatar_url":"https://avatars.githubusercontent.com/u/22186721?v=3","gravatar_id":"","url":"https://api.github.com/users/quanvhframgia","html_url":"https://github.com/quanvhframgia","followers_url":"https://api.github.com/users/quanvhframgia/followers","following_url":"https://api.github.com/users/quanvhframgia/following{/other_user}","gists_url":"https://api.github.com/users/quanvhframgia/gists{/gist_id}","starred_url":"https://api.github.com/users/quanvhframgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quanvhframgia/subscriptions","organizations_url":"https://api.github.com/users/quanvhframgia/orgs","repos_url":"https://api.github.com/users/quanvhframgia/repos","events_url":"https://api.github.com/users/quanvhframgia/events{/privacy}","received_events_url":"https://api.github.com/users/quanvhframgia/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-23T03:22:25Z","updated_at":"2016-09-23T09:48:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fa3e3701e7a2db862919ea0071d00bf128ae474","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/framgia/fels_186/pulls/8/commits","review_comments_url":"https://api.github.com/repos/framgia/fels_186/pulls/8/comments","review_comment_url":"https://api.github.com/repos/framgia/fels_186/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/fels_186/issues/8/comments","statuses_url":"https://api.github.com/repos/framgia/fels_186/statuses/4e737d6df59b4499d1ee9e8025e2000fab37fb4d","head":{"label":"quanvhframgia:repositories","ref":"repositories","sha":"4e737d6df59b4499d1ee9e8025e2000fab37fb4d","user":{"login":"quanvhframgia","id":22186721,"avatar_url":"https://avatars.githubusercontent.com/u/22186721?v=3","gravatar_id":"","url":"https://api.github.com/users/quanvhframgia","html_url":"https://github.com/quanvhframgia","followers_url":"https://api.github.com/users/quanvhframgia/followers","following_url":"https://api.github.com/users/quanvhframgia/following{/other_user}","gists_url":"https://api.github.com/users/quanvhframgia/gists{/gist_id}","starred_url":"https://api.github.com/users/quanvhframgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quanvhframgia/subscriptions","organizations_url":"https://api.github.com/users/quanvhframgia/orgs","repos_url":"https://api.github.com/users/quanvhframgia/repos","events_url":"https://api.github.com/users/quanvhframgia/events{/privacy}","received_events_url":"https://api.github.com/users/quanvhframgia/received_events","type":"User","site_admin":false},"repo":{"id":68587497,"name":"fels_186","full_name":"quanvhframgia/fels_186","owner":{"login":"quanvhframgia","id":22186721,"avatar_url":"https://avatars.githubusercontent.com/u/22186721?v=3","gravatar_id":"","url":"https://api.github.com/users/quanvhframgia","html_url":"https://github.com/quanvhframgia","followers_url":"https://api.github.com/users/quanvhframgia/followers","following_url":"https://api.github.com/users/quanvhframgia/following{/other_user}","gists_url":"https://api.github.com/users/quanvhframgia/gists{/gist_id}","starred_url":"https://api.github.com/users/quanvhframgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quanvhframgia/subscriptions","organizations_url":"https://api.github.com/users/quanvhframgia/orgs","repos_url":"https://api.github.com/users/quanvhframgia/repos","events_url":"https://api.github.com/users/quanvhframgia/events{/privacy}","received_events_url":"https://api.github.com/users/quanvhframgia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/quanvhframgia/fels_186","description":"Framgia E Learning System (Training)","fork":true,"url":"https://api.github.com/repos/quanvhframgia/fels_186","forks_url":"https://api.github.com/repos/quanvhframgia/fels_186/forks","keys_url":"https://api.github.com/repos/quanvhframgia/fels_186/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quanvhframgia/fels_186/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quanvhframgia/fels_186/teams","hooks_url":"https://api.github.com/repos/quanvhframgia/fels_186/hooks","issue_events_url":"https://api.github.com/repos/quanvhframgia/fels_186/issues/events{/number}","events_url":"https://api.github.com/repos/quanvhframgia/fels_186/events","assignees_url":"https://api.github.com/repos/quanvhframgia/fels_186/assignees{/user}","branches_url":"https://api.github.com/repos/quanvhframgia/fels_186/branches{/branch}","tags_url":"https://api.github.com/repos/quanvhframgia/fels_186/tags","blobs_url":"https://api.github.com/repos/quanvhframgia/fels_186/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quanvhframgia/fels_186/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quanvhframgia/fels_186/git/refs{/sha}","trees_url":"https://api.github.com/repos/quanvhframgia/fels_186/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quanvhframgia/fels_186/statuses/{sha}","languages_url":"https://api.github.com/repos/quanvhframgia/fels_186/languages","stargazers_url":"https://api.github.com/repos/quanvhframgia/fels_186/stargazers","contributors_url":"https://api.github.com/repos/quanvhframgia/fels_186/contributors","subscribers_url":"https://api.github.com/repos/quanvhframgia/fels_186/subscribers","subscription_url":"https://api.github.com/repos/quanvhframgia/fels_186/subscription","commits_url":"https://api.github.com/repos/quanvhframgia/fels_186/commits{/sha}","git_commits_url":"https://api.github.com/repos/quanvhframgia/fels_186/git/commits{/sha}","comments_url":"https://api.github.com/repos/quanvhframgia/fels_186/comments{/number}","issue_comment_url":"https://api.github.com/repos/quanvhframgia/fels_186/issues/comments{/number}","contents_url":"https://api.github.com/repos/quanvhframgia/fels_186/contents/{+path}","compare_url":"https://api.github.com/repos/quanvhframgia/fels_186/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quanvhframgia/fels_186/merges","archive_url":"https://api.github.com/repos/quanvhframgia/fels_186/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quanvhframgia/fels_186/downloads","issues_url":"https://api.github.com/repos/quanvhframgia/fels_186/issues{/number}","pulls_url":"https://api.github.com/repos/quanvhframgia/fels_186/pulls{/number}","milestones_url":"https://api.github.com/repos/quanvhframgia/fels_186/milestones{/number}","notifications_url":"https://api.github.com/repos/quanvhframgia/fels_186/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quanvhframgia/fels_186/labels{/name}","releases_url":"https://api.github.com/repos/quanvhframgia/fels_186/releases{/id}","deployments_url":"https://api.github.com/repos/quanvhframgia/fels_186/deployments","created_at":"2016-09-19T08:54:54Z","updated_at":"2016-09-19T02:00:34Z","pushed_at":"2016-09-23T09:02:17Z","git_url":"git://github.com/quanvhframgia/fels_186.git","ssh_url":"git@github.com:quanvhframgia/fels_186.git","clone_url":"https://github.com/quanvhframgia/fels_186.git","svn_url":"https://github.com/quanvhframgia/fels_186","homepage":null,"size":526,"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":"4703af862ae04a1e2a35792551e3b3f05a6c704c","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":68560148,"name":"fels_186","full_name":"framgia/fels_186","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_186","description":"Framgia E Learning System (Training)","fork":false,"url":"https://api.github.com/repos/framgia/fels_186","forks_url":"https://api.github.com/repos/framgia/fels_186/forks","keys_url":"https://api.github.com/repos/framgia/fels_186/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/fels_186/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/fels_186/teams","hooks_url":"https://api.github.com/repos/framgia/fels_186/hooks","issue_events_url":"https://api.github.com/repos/framgia/fels_186/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/fels_186/events","assignees_url":"https://api.github.com/repos/framgia/fels_186/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/fels_186/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/fels_186/tags","blobs_url":"https://api.github.com/repos/framgia/fels_186/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/fels_186/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/fels_186/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/fels_186/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/fels_186/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/fels_186/languages","stargazers_url":"https://api.github.com/repos/framgia/fels_186/stargazers","contributors_url":"https://api.github.com/repos/framgia/fels_186/contributors","subscribers_url":"https://api.github.com/repos/framgia/fels_186/subscribers","subscription_url":"https://api.github.com/repos/framgia/fels_186/subscription","commits_url":"https://api.github.com/repos/framgia/fels_186/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/fels_186/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/fels_186/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/fels_186/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/fels_186/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/fels_186/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/fels_186/merges","archive_url":"https://api.github.com/repos/framgia/fels_186/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/fels_186/downloads","issues_url":"https://api.github.com/repos/framgia/fels_186/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/fels_186/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/fels_186/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/fels_186/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/fels_186/labels{/name}","releases_url":"https://api.github.com/repos/framgia/fels_186/releases{/id}","deployments_url":"https://api.github.com/repos/framgia/fels_186/deployments","created_at":"2016-09-19T02:00:34Z","updated_at":"2016-09-19T09:08:56Z","pushed_at":"2016-09-23T09:02:17Z","git_url":"git://github.com/framgia/fels_186.git","ssh_url":"git@github.com:framgia/fels_186.git","clone_url":"https://github.com/framgia/fels_186.git","svn_url":"https://github.com/framgia/fels_186","homepage":null,"size":523,"stargazers_count":0,"watchers_count":0,"language":"PHP","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_186/pulls/8"},"html":{"href":"https://github.com/framgia/fels_186/pull/8"},"issue":{"href":"https://api.github.com/repos/framgia/fels_186/issues/8"},"comments":{"href":"https://api.github.com/repos/framgia/fels_186/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/fels_186/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/fels_186/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/fels_186/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/fels_186/statuses/4e737d6df59b4499d1ee9e8025e2000fab37fb4d"}}}}
{"actor":{"display_login":"huynguyenframgia"}}