GitHub PullRequestEvent at 2014-06-19 09:43:33
Repository: laravel-repository
Actor: anlutro
Payload: {"action":"opened","number":2,"pull_request":{"url":"https://api.github.com/repos/anlutro/laravel-repository/pulls/2","id":17341566,"html_url":"https://github.com/anlutro/laravel-repository/pull/2","diff_url":"https://github.com/anlutro/laravel-repository/pull/2.diff","patch_url":"https://github.com/anlutro/laravel-repository/pull/2.patch","issue_url":"https://api.github.com/repos/anlutro/laravel-repository/issues/2","number":2,"state":"open","title":"Criteria","user":{"login":"anlutro","id":163093,"avatar_url":"https://avatars.githubusercontent.com/u/163093?","gravatar_id":"040a355679c41bfe29a4a69fd655af22","url":"https://api.github.com/users/anlutro","html_url":"https://github.com/anlutro","followers_url":"https://api.github.com/users/anlutro/followers","following_url":"https://api.github.com/users/anlutro/following{/other_user}","gists_url":"https://api.github.com/users/anlutro/gists{/gist_id}","starred_url":"https://api.github.com/users/anlutro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anlutro/subscriptions","organizations_url":"https://api.github.com/users/anlutro/orgs","repos_url":"https://api.github.com/users/anlutro/repos","events_url":"https://api.github.com/users/anlutro/events{/privacy}","received_events_url":"https://api.github.com/users/anlutro/received_events","type":"User","site_admin":false},"body":"Core idea: Class representations of criteria that a query must match. Criteria can contain state and other various information that affect how it affects the query.\r\n\r\n```php\r\n<?php\r\n$repo = new MyRepository(/* ... */);\r\n$criteria = new MyCriteria();\r\n$criteria->setUser($user);\r\n$criteria->setProject($project);\r\n$repo->getForCriteria($criteria);\r\n\r\nclass MyRepository extends DatabaseRepository\r\n{\r\n\tpublic function getForProject(Project $project)\r\n\t{\r\n\t\t$criteria = new MyCriteria();\r\n\t\t$criteria->setProject($project);\r\n\t\t$this->pushCriteria($criteria);\r\n\t\treturn $this->getAll();\r\n\t}\r\n\r\n\tpublic function getForUser(User $user)\r\n\t{\r\n\t\t$criteria = new MyCriteria();\r\n\t\t$criteria->setUser($user);\r\n\t\t$this->pushCriteria($criteria);\r\n\t\treturn $this->getAll();\r\n\t}\r\n\r\n\tpublic function getForProjectUser(Project $project, User $user)\r\n\t{\r\n\t\t$criteria = new MyCriteria();\r\n\t\t$criteria->setUser($user);\r\n\t\t$criteria->setProject($project);\r\n\t\treturn $this->getAll();\r\n\t}\r\n\r\n\tpublic function getFilterInstance()\r\n\t{\r\n\t\treturn new MyFilter($this);\r\n\t}\r\n}\r\n\r\nclass MyCriteria implements CriteriaInterface\r\n{\r\n\tprotected $project;\r\n\tprotected $user;\r\n\r\n\tpublic function setProject(Project $project)\r\n\t{\r\n\t\t$this->project = $project;\r\n\t}\r\n\r\n\tpublic function setUser(User $user)\r\n\t{\r\n\t\t$this->user = $user;\r\n\t}\r\n\r\n\tpublic function apply($query)\r\n\t{\r\n\t\tif ($this->project) {\r\n\t\t\t// lots of intricate joins here maybe?\r\n\t\t\t$query->where('project_id', '=', $this->project->getKey());\r\n\t\t}\r\n\r\n\t\tif ($this->user) {\r\n\t\t\t// lots of intricate joins here maybe?\r\n\t\t\t$query->where('user_id', '=', $this->user->getKey());\r\n\t\t}\r\n\t}\r\n}\r\n```","created_at":"2014-06-19T09:43:30Z","updated_at":"2014-06-19T09:43:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"42d1a0c333e7af111b716d379a0de178b3bc042b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/anlutro/laravel-repository/pulls/2/commits","review_comments_url":"https://api.github.com/repos/anlutro/laravel-repository/pulls/2/comments","review_comment_url":"https://api.github.com/repos/anlutro/laravel-repository/pulls/comments/{number}","comments_url":"https://api.github.com/repos/anlutro/laravel-repository/issues/2/comments","statuses_url":"https://api.github.com/repos/anlutro/laravel-repository/statuses/26594083e11372dda90a52d4fb44cc97fba22332","head":{"label":"anlutro:feature/criteria","ref":"feature/criteria","sha":"26594083e11372dda90a52d4fb44cc97fba22332","user":{"login":"anlutro","id":163093,"avatar_url":"https://avatars.githubusercontent.com/u/163093?","gravatar_id":"040a355679c41bfe29a4a69fd655af22","url":"https://api.github.com/users/anlutro","html_url":"https://github.com/anlutro","followers_url":"https://api.github.com/users/anlutro/followers","following_url":"https://api.github.com/users/anlutro/following{/other_user}","gists_url":"https://api.github.com/users/anlutro/gists{/gist_id}","starred_url":"https://api.github.com/users/anlutro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anlutro/subscriptions","organizations_url":"https://api.github.com/users/anlutro/orgs","repos_url":"https://api.github.com/users/anlutro/repos","events_url":"https://api.github.com/users/anlutro/events{/privacy}","received_events_url":"https://api.github.com/users/anlutro/received_events","type":"User","site_admin":false},"repo":{"id":15865208,"name":"laravel-repository","full_name":"anlutro/laravel-repository","owner":{"login":"anlutro","id":163093,"avatar_url":"https://avatars.githubusercontent.com/u/163093?","gravatar_id":"040a355679c41bfe29a4a69fd655af22","url":"https://api.github.com/users/anlutro","html_url":"https://github.com/anlutro","followers_url":"https://api.github.com/users/anlutro/followers","following_url":"https://api.github.com/users/anlutro/following{/other_user}","gists_url":"https://api.github.com/users/anlutro/gists{/gist_id}","starred_url":"https://api.github.com/users/anlutro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anlutro/subscriptions","organizations_url":"https://api.github.com/users/anlutro/orgs","repos_url":"https://api.github.com/users/anlutro/repos","events_url":"https://api.github.com/users/anlutro/events{/privacy}","received_events_url":"https://api.github.com/users/anlutro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/anlutro/laravel-repository","description":"Laravel 4 Repository classes","fork":false,"url":"https://api.github.com/repos/anlutro/laravel-repository","forks_url":"https://api.github.com/repos/anlutro/laravel-repository/forks","keys_url":"https://api.github.com/repos/anlutro/laravel-repository/keys{/key_id}","collaborators_url":"https://api.github.com/repos/anlutro/laravel-repository/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/anlutro/laravel-repository/teams","hooks_url":"https://api.github.com/repos/anlutro/laravel-repository/hooks","issue_events_url":"https://api.github.com/repos/anlutro/laravel-repository/issues/events{/number}","events_url":"https://api.github.com/repos/anlutro/laravel-repository/events","assignees_url":"https://api.github.com/repos/anlutro/laravel-repository/assignees{/user}","branches_url":"https://api.github.com/repos/anlutro/laravel-repository/branches{/branch}","tags_url":"https://api.github.com/repos/anlutro/laravel-repository/tags","blobs_url":"https://api.github.com/repos/anlutro/laravel-repository/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/anlutro/laravel-repository/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/anlutro/laravel-repository/git/refs{/sha}","trees_url":"https://api.github.com/repos/anlutro/laravel-repository/git/trees{/sha}","statuses_url":"https://api.github.com/repos/anlutro/laravel-repository/statuses/{sha}","languages_url":"https://api.github.com/repos/anlutro/laravel-repository/languages","stargazers_url":"https://api.github.com/repos/anlutro/laravel-repository/stargazers","contributors_url":"https://api.github.com/repos/anlutro/laravel-repository/contributors","subscribers_url":"https://api.github.com/repos/anlutro/laravel-repository/subscribers","subscription_url":"https://api.github.com/repos/anlutro/laravel-repository/subscription","commits_url":"https://api.github.com/repos/anlutro/laravel-repository/commits{/sha}","git_commits_url":"https://api.github.com/repos/anlutro/laravel-repository/git/commits{/sha}","comments_url":"https://api.github.com/repos/anlutro/laravel-repository/comments{/number}","issue_comment_url":"https://api.github.com/repos/anlutro/laravel-repository/issues/comments/{number}","contents_url":"https://api.github.com/repos/anlutro/laravel-repository/contents/{+path}","compare_url":"https://api.github.com/repos/anlutro/laravel-repository/compare/{base}...{head}","merges_url":"https://api.github.com/repos/anlutro/laravel-repository/merges","archive_url":"https://api.github.com/repos/anlutro/laravel-repository/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/anlutro/laravel-repository/downloads","issues_url":"https://api.github.com/repos/anlutro/laravel-repository/issues{/number}","pulls_url":"https://api.github.com/repos/anlutro/laravel-repository/pulls{/number}","milestones_url":"https://api.github.com/repos/anlutro/laravel-repository/milestones{/number}","notifications_url":"https://api.github.com/repos/anlutro/laravel-repository/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/anlutro/laravel-repository/labels{/name}","releases_url":"https://api.github.com/repos/anlutro/laravel-repository/releases{/id}","created_at":"2014-01-13T10:36:27Z","updated_at":"2014-06-19T09:43:30Z","pushed_at":"2014-06-19T09:39:06Z","git_url":"git://github.com/anlutro/laravel-repository.git","ssh_url":"git@github.com:anlutro/laravel-repository.git","clone_url":"https://github.com/anlutro/laravel-repository.git","svn_url":"https://github.com/anlutro/laravel-repository","homepage":null,"size":621,"stargazers_count":26,"watchers_count":26,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":26,"default_branch":"master"}},"base":{"label":"anlutro:master","ref":"master","sha":"ec54ffddb49f479430eb232ef855d7a2871d0f3c","user":{"login":"anlutro","id":163093,"avatar_url":"https://avatars.githubusercontent.com/u/163093?","gravatar_id":"040a355679c41bfe29a4a69fd655af22","url":"https://api.github.com/users/anlutro","html_url":"https://github.com/anlutro","followers_url":"https://api.github.com/users/anlutro/followers","following_url":"https://api.github.com/users/anlutro/following{/other_user}","gists_url":"https://api.github.com/users/anlutro/gists{/gist_id}","starred_url":"https://api.github.com/users/anlutro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anlutro/subscriptions","organizations_url":"https://api.github.com/users/anlutro/orgs","repos_url":"https://api.github.com/users/anlutro/repos","events_url":"https://api.github.com/users/anlutro/events{/privacy}","received_events_url":"https://api.github.com/users/anlutro/received_events","type":"User","site_admin":false},"repo":{"id":15865208,"name":"laravel-repository","full_name":"anlutro/laravel-repository","owner":{"login":"anlutro","id":163093,"avatar_url":"https://avatars.githubusercontent.com/u/163093?","gravatar_id":"040a355679c41bfe29a4a69fd655af22","url":"https://api.github.com/users/anlutro","html_url":"https://github.com/anlutro","followers_url":"https://api.github.com/users/anlutro/followers","following_url":"https://api.github.com/users/anlutro/following{/other_user}","gists_url":"https://api.github.com/users/anlutro/gists{/gist_id}","starred_url":"https://api.github.com/users/anlutro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anlutro/subscriptions","organizations_url":"https://api.github.com/users/anlutro/orgs","repos_url":"https://api.github.com/users/anlutro/repos","events_url":"https://api.github.com/users/anlutro/events{/privacy}","received_events_url":"https://api.github.com/users/anlutro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/anlutro/laravel-repository","description":"Laravel 4 Repository classes","fork":false,"url":"https://api.github.com/repos/anlutro/laravel-repository","forks_url":"https://api.github.com/repos/anlutro/laravel-repository/forks","keys_url":"https://api.github.com/repos/anlutro/laravel-repository/keys{/key_id}","collaborators_url":"https://api.github.com/repos/anlutro/laravel-repository/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/anlutro/laravel-repository/teams","hooks_url":"https://api.github.com/repos/anlutro/laravel-repository/hooks","issue_events_url":"https://api.github.com/repos/anlutro/laravel-repository/issues/events{/number}","events_url":"https://api.github.com/repos/anlutro/laravel-repository/events","assignees_url":"https://api.github.com/repos/anlutro/laravel-repository/assignees{/user}","branches_url":"https://api.github.com/repos/anlutro/laravel-repository/branches{/branch}","tags_url":"https://api.github.com/repos/anlutro/laravel-repository/tags","blobs_url":"https://api.github.com/repos/anlutro/laravel-repository/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/anlutro/laravel-repository/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/anlutro/laravel-repository/git/refs{/sha}","trees_url":"https://api.github.com/repos/anlutro/laravel-repository/git/trees{/sha}","statuses_url":"https://api.github.com/repos/anlutro/laravel-repository/statuses/{sha}","languages_url":"https://api.github.com/repos/anlutro/laravel-repository/languages","stargazers_url":"https://api.github.com/repos/anlutro/laravel-repository/stargazers","contributors_url":"https://api.github.com/repos/anlutro/laravel-repository/contributors","subscribers_url":"https://api.github.com/repos/anlutro/laravel-repository/subscribers","subscription_url":"https://api.github.com/repos/anlutro/laravel-repository/subscription","commits_url":"https://api.github.com/repos/anlutro/laravel-repository/commits{/sha}","git_commits_url":"https://api.github.com/repos/anlutro/laravel-repository/git/commits{/sha}","comments_url":"https://api.github.com/repos/anlutro/laravel-repository/comments{/number}","issue_comment_url":"https://api.github.com/repos/anlutro/laravel-repository/issues/comments/{number}","contents_url":"https://api.github.com/repos/anlutro/laravel-repository/contents/{+path}","compare_url":"https://api.github.com/repos/anlutro/laravel-repository/compare/{base}...{head}","merges_url":"https://api.github.com/repos/anlutro/laravel-repository/merges","archive_url":"https://api.github.com/repos/anlutro/laravel-repository/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/anlutro/laravel-repository/downloads","issues_url":"https://api.github.com/repos/anlutro/laravel-repository/issues{/number}","pulls_url":"https://api.github.com/repos/anlutro/laravel-repository/pulls{/number}","milestones_url":"https://api.github.com/repos/anlutro/laravel-repository/milestones{/number}","notifications_url":"https://api.github.com/repos/anlutro/laravel-repository/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/anlutro/laravel-repository/labels{/name}","releases_url":"https://api.github.com/repos/anlutro/laravel-repository/releases{/id}","created_at":"2014-01-13T10:36:27Z","updated_at":"2014-06-19T09:43:30Z","pushed_at":"2014-06-19T09:39:06Z","git_url":"git://github.com/anlutro/laravel-repository.git","ssh_url":"git@github.com:anlutro/laravel-repository.git","clone_url":"https://github.com/anlutro/laravel-repository.git","svn_url":"https://github.com/anlutro/laravel-repository","homepage":null,"size":621,"stargazers_count":26,"watchers_count":26,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/anlutro/laravel-repository/pulls/2"},"html":{"href":"https://github.com/anlutro/laravel-repository/pull/2"},"issue":{"href":"https://api.github.com/repos/anlutro/laravel-repository/issues/2"},"comments":{"href":"https://api.github.com/repos/anlutro/laravel-repository/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/anlutro/laravel-repository/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/anlutro/laravel-repository/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/anlutro/laravel-repository/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/anlutro/laravel-repository/statuses/26594083e11372dda90a52d4fb44cc97fba22332"}},"merged":false,"mergeable":true,"mergeable_state":"unstable","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":125,"deletions":0,"changed_files":4}}