{"action":"created","comment":{"url":"https://api.github.com/repos/owen-it/laravel-auditing/pulls/comments/143360289","pull_request_review_id":67862859,"id":143360289,"diff_hunk":"@@ -79,10 +81,54 @@ public function execute(AuditableContract $model)\n             return;\n         }\n \n-        if ($audit = $driver->audit($model)) {\n+        if ($audit = $driver->audit($model, null)) {\n             $driver->prune($model);\n         }\n \n+        if($model->getAuditRelatedProperties())\n+        {\n+            $audit->relation_id = $audit->id;\n+            $audit->save();\n+        }\n+        foreach ($model->getAuditRelatedProperties() as $methodOrPropertyName) {\n+            if(property_exists ($model , $methodOrPropertyName ))\n+            {\n+                $methodResult = $model->$methodOrPropertyName;\n+            }","path":"src/Auditor.php","position":27,"original_position":27,"commit_id":"23027dfa2e440c5b3ace59ddeede6ef4b28e8dc5","original_commit_id":"23027dfa2e440c5b3ace59ddeede6ef4b28e8dc5","user":{"login":"Nitpick-CI","id":12626182,"avatar_url":"https://avatars1.githubusercontent.com/u/12626182?v=4","gravatar_id":"","url":"https://api.github.com/users/Nitpick-CI","html_url":"https://github.com/Nitpick-CI","followers_url":"https://api.github.com/users/Nitpick-CI/followers","following_url":"https://api.github.com/users/Nitpick-CI/following{/other_user}","gists_url":"https://api.github.com/users/Nitpick-CI/gists{/gist_id}","starred_url":"https://api.github.com/users/Nitpick-CI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nitpick-CI/subscriptions","organizations_url":"https://api.github.com/users/Nitpick-CI/orgs","repos_url":"https://api.github.com/users/Nitpick-CI/repos","events_url":"https://api.github.com/users/Nitpick-CI/events{/privacy}","received_events_url":"https://api.github.com/users/Nitpick-CI/received_events","type":"User","site_admin":false},"body":"Expected 1 space after closing brace; newline found","created_at":"2017-10-08T17:05:14Z","updated_at":"2017-10-08T17:05:14Z","html_url":"https://github.com/owen-it/laravel-auditing/pull/321#discussion_r143360289","pull_request_url":"https://api.github.com/repos/owen-it/laravel-auditing/pulls/321","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/owen-it/laravel-auditing/pulls/comments/143360289"},"html":{"href":"https://github.com/owen-it/laravel-auditing/pull/321#discussion_r143360289"},"pull_request":{"href":"https://api.github.com/repos/owen-it/laravel-auditing/pulls/321"}}},"pull_request":{"url":"https://api.github.com/repos/owen-it/laravel-auditing/pulls/321","id":144036741,"html_url":"https://github.com/owen-it/laravel-auditing/pull/321","diff_url":"https://github.com/owen-it/laravel-auditing/pull/321.diff","patch_url":"https://github.com/owen-it/laravel-auditing/pull/321.patch","issue_url":"https://api.github.com/repos/owen-it/laravel-auditing/issues/321","number":321,"state":"open","locked":false,"title":"related_relations","user":{"login":"jschlies","id":2206903,"avatar_url":"https://avatars3.githubusercontent.com/u/2206903?v=4","gravatar_id":"","url":"https://api.github.com/users/jschlies","html_url":"https://github.com/jschlies","followers_url":"https://api.github.com/users/jschlies/followers","following_url":"https://api.github.com/users/jschlies/following{/other_user}","gists_url":"https://api.github.com/users/jschlies/gists{/gist_id}","starred_url":"https://api.github.com/users/jschlies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jschlies/subscriptions","organizations_url":"https://api.github.com/users/jschlies/orgs","repos_url":"https://api.github.com/users/jschlies/repos","events_url":"https://api.github.com/users/jschlies/events{/privacy}","received_events_url":"https://api.github.com/users/jschlies/received_events","type":"User","site_admin":false},"body":"Add ability to collect and retrieve audits on related objects. \r\n\r\nExample: Say you need to maintain an accessLists to define which **Users** have access to which **Resources**. You could create the following database tables/models:  AccessLists, Users and Resources,with 'connector' tables/models AccessListUsers and AccessListResources. You could, with the current functionality, audit all 5 tables and somehow cobble together a picture if the full history of a particular AccessList but that picture would have issues. Say a user is added, then deleted and then re-added. Using only current functionality, it would be very hard to create the history of that AccessList that includes the Users first membership.\r\n\r\nRelated Relations seeks to solve this.\r\n\r\nIndicate the model(s) (relating model) that you want to retain related relations for. For each, indicate the 'propertys' or 'methods' of that relating model that returns returns related objects. 'Yields' is the type of object returned. This results in $AuditObj's with a 'event' of 'related' and (with a call to $AuditObj->getRelatingAudit), the audit object of that is related.\r\n\r\nTo implement the above example using Related Relations to record activity :\r\nAdd the following to the AccessListUsers and AccessListResources  models.\r\n\r\nclass AccessListUsers extends Model implements AuditableContract, UserResolver\r\n{\r\n    use AuditableTrait;\r\n\r\n    protected $auditRelatedProperties = [  'accessList'];\r\n}\r\nclass AccessListResources extends Model implements AuditableContract, UserResolver\r\n{\r\n    use AuditableTrait;\r\n\r\n    protected $auditRelatedProperties = [  'accessList'];\r\n}\r\n\r\nWith this, when AccessListUsers or  AccessListResources are added, deleted or updated, an additional 'related' audit of the AccessLists model is taken and tied to the AccessListUsers or AccessListResource audit via relatuion_id.\r\n\r\nThus after adding an AccessListUsers, AccessLists->audits() will return an array of audit objects, One of which will have an 'event' value of related. The 'related' thing is accessable from that audit via Audit->getRelated().\r\n\r\nNote that 'relation' here means more that Eloquent relation. $auditRelatedProperties needs to be a list of methods or properties that return an Eloquent object (or collection of objects) that have the Auditable trait and return an  obg. the  methods or properties. \r\n \r\nBE CAREFUL!!!! Be thoughtful of which relations you try to audit. This can create HUGE db traffic and should be used in a limited manner. If stress testing for any implementation of this.","created_at":"2017-09-30T17:25:11Z","updated_at":"2017-10-08T17:05:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed057c7d9b7d74f2a379262076e26439302a77cf","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/owen-it/laravel-auditing/pulls/321/commits","review_comments_url":"https://api.github.com/repos/owen-it/laravel-auditing/pulls/321/comments","review_comment_url":"https://api.github.com/repos/owen-it/laravel-auditing/pulls/comments{/number}","comments_url":"https://api.github.com/repos/owen-it/laravel-auditing/issues/321/comments","statuses_url":"https://api.github.com/repos/owen-it/laravel-auditing/statuses/23027dfa2e440c5b3ace59ddeede6ef4b28e8dc5","head":{"label":"jschlies:related_relations","ref":"related_relations","sha":"23027dfa2e440c5b3ace59ddeede6ef4b28e8dc5","user":{"login":"jschlies","id":2206903,"avatar_url":"https://avatars3.githubusercontent.com/u/2206903?v=4","gravatar_id":"","url":"https://api.github.com/users/jschlies","html_url":"https://github.com/jschlies","followers_url":"https://api.github.com/users/jschlies/followers","following_url":"https://api.github.com/users/jschlies/following{/other_user}","gists_url":"https://api.github.com/users/jschlies/gists{/gist_id}","starred_url":"https://api.github.com/users/jschlies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jschlies/subscriptions","organizations_url":"https://api.github.com/users/jschlies/orgs","repos_url":"https://api.github.com/users/jschlies/repos","events_url":"https://api.github.com/users/jschlies/events{/privacy}","received_events_url":"https://api.github.com/users/jschlies/received_events","type":"User","site_admin":false},"repo":{"id":78363891,"name":"laravel-auditing","full_name":"jschlies/laravel-auditing","owner":{"login":"jschlies","id":2206903,"avatar_url":"https://avatars3.githubusercontent.com/u/2206903?v=4","gravatar_id":"","url":"https://api.github.com/users/jschlies","html_url":"https://github.com/jschlies","followers_url":"https://api.github.com/users/jschlies/followers","following_url":"https://api.github.com/users/jschlies/following{/other_user}","gists_url":"https://api.github.com/users/jschlies/gists{/gist_id}","starred_url":"https://api.github.com/users/jschlies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jschlies/subscriptions","organizations_url":"https://api.github.com/users/jschlies/orgs","repos_url":"https://api.github.com/users/jschlies/repos","events_url":"https://api.github.com/users/jschlies/events{/privacy}","received_events_url":"https://api.github.com/users/jschlies/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jschlies/laravel-auditing","description":"Record the change log from models in Laravel","fork":true,"url":"https://api.github.com/repos/jschlies/laravel-auditing","forks_url":"https://api.github.com/repos/jschlies/laravel-auditing/forks","keys_url":"https://api.github.com/repos/jschlies/laravel-auditing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jschlies/laravel-auditing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jschlies/laravel-auditing/teams","hooks_url":"https://api.github.com/repos/jschlies/laravel-auditing/hooks","issue_events_url":"https://api.github.com/repos/jschlies/laravel-auditing/issues/events{/number}","events_url":"https://api.github.com/repos/jschlies/laravel-auditing/events","assignees_url":"https://api.github.com/repos/jschlies/laravel-auditing/assignees{/user}","branches_url":"https://api.github.com/repos/jschlies/laravel-auditing/branches{/branch}","tags_url":"https://api.github.com/repos/jschlies/laravel-auditing/tags","blobs_url":"https://api.github.com/repos/jschlies/laravel-auditing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jschlies/laravel-auditing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jschlies/laravel-auditing/git/refs{/sha}","trees_url":"https://api.github.com/repos/jschlies/laravel-auditing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jschlies/laravel-auditing/statuses/{sha}","languages_url":"https://api.github.com/repos/jschlies/laravel-auditing/languages","stargazers_url":"https://api.github.com/repos/jschlies/laravel-auditing/stargazers","contributors_url":"https://api.github.com/repos/jschlies/laravel-auditing/contributors","subscribers_url":"https://api.github.com/repos/jschlies/laravel-auditing/subscribers","subscription_url":"https://api.github.com/repos/jschlies/laravel-auditing/subscription","commits_url":"https://api.github.com/repos/jschlies/laravel-auditing/commits{/sha}","git_commits_url":"https://api.github.com/repos/jschlies/laravel-auditing/git/commits{/sha}","comments_url":"https://api.github.com/repos/jschlies/laravel-auditing/comments{/number}","issue_comment_url":"https://api.github.com/repos/jschlies/laravel-auditing/issues/comments{/number}","contents_url":"https://api.github.com/repos/jschlies/laravel-auditing/contents/{+path}","compare_url":"https://api.github.com/repos/jschlies/laravel-auditing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jschlies/laravel-auditing/merges","archive_url":"https://api.github.com/repos/jschlies/laravel-auditing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jschlies/laravel-auditing/downloads","issues_url":"https://api.github.com/repos/jschlies/laravel-auditing/issues{/number}","pulls_url":"https://api.github.com/repos/jschlies/laravel-auditing/pulls{/number}","milestones_url":"https://api.github.com/repos/jschlies/laravel-auditing/milestones{/number}","notifications_url":"https://api.github.com/repos/jschlies/laravel-auditing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jschlies/laravel-auditing/labels{/name}","releases_url":"https://api.github.com/repos/jschlies/laravel-auditing/releases{/id}","deployments_url":"https://api.github.com/repos/jschlies/laravel-auditing/deployments","created_at":"2017-01-08T18:59:29Z","updated_at":"2017-01-08T18:59:34Z","pushed_at":"2017-10-08T17:04:57Z","git_url":"git://github.com/jschlies/laravel-auditing.git","ssh_url":"git@github.com:jschlies/laravel-auditing.git","clone_url":"https://github.com/jschlies/laravel-auditing.git","svn_url":"https://github.com/jschlies/laravel-auditing","homepage":"","size":427,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_projects":true,"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":"3.1"}},"base":{"label":"owen-it:4.1","ref":"4.1","sha":"8a8295122d6e2f839b871d87df0c8d7054ceedd5","user":{"login":"owen-it","id":13595876,"avatar_url":"https://avatars2.githubusercontent.com/u/13595876?v=4","gravatar_id":"","url":"https://api.github.com/users/owen-it","html_url":"https://github.com/owen-it","followers_url":"https://api.github.com/users/owen-it/followers","following_url":"https://api.github.com/users/owen-it/following{/other_user}","gists_url":"https://api.github.com/users/owen-it/gists{/gist_id}","starred_url":"https://api.github.com/users/owen-it/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owen-it/subscriptions","organizations_url":"https://api.github.com/users/owen-it/orgs","repos_url":"https://api.github.com/users/owen-it/repos","events_url":"https://api.github.com/users/owen-it/events{/privacy}","received_events_url":"https://api.github.com/users/owen-it/received_events","type":"Organization","site_admin":false},"repo":{"id":41092552,"name":"laravel-auditing","full_name":"owen-it/laravel-auditing","owner":{"login":"owen-it","id":13595876,"avatar_url":"https://avatars2.githubusercontent.com/u/13595876?v=4","gravatar_id":"","url":"https://api.github.com/users/owen-it","html_url":"https://github.com/owen-it","followers_url":"https://api.github.com/users/owen-it/followers","following_url":"https://api.github.com/users/owen-it/following{/other_user}","gists_url":"https://api.github.com/users/owen-it/gists{/gist_id}","starred_url":"https://api.github.com/users/owen-it/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owen-it/subscriptions","organizations_url":"https://api.github.com/users/owen-it/orgs","repos_url":"https://api.github.com/users/owen-it/repos","events_url":"https://api.github.com/users/owen-it/events{/privacy}","received_events_url":"https://api.github.com/users/owen-it/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/owen-it/laravel-auditing","description":"Record the change log from models in Laravel","fork":false,"url":"https://api.github.com/repos/owen-it/laravel-auditing","forks_url":"https://api.github.com/repos/owen-it/laravel-auditing/forks","keys_url":"https://api.github.com/repos/owen-it/laravel-auditing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/owen-it/laravel-auditing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/owen-it/laravel-auditing/teams","hooks_url":"https://api.github.com/repos/owen-it/laravel-auditing/hooks","issue_events_url":"https://api.github.com/repos/owen-it/laravel-auditing/issues/events{/number}","events_url":"https://api.github.com/repos/owen-it/laravel-auditing/events","assignees_url":"https://api.github.com/repos/owen-it/laravel-auditing/assignees{/user}","branches_url":"https://api.github.com/repos/owen-it/laravel-auditing/branches{/branch}","tags_url":"https://api.github.com/repos/owen-it/laravel-auditing/tags","blobs_url":"https://api.github.com/repos/owen-it/laravel-auditing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/owen-it/laravel-auditing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/owen-it/laravel-auditing/git/refs{/sha}","trees_url":"https://api.github.com/repos/owen-it/laravel-auditing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/owen-it/laravel-auditing/statuses/{sha}","languages_url":"https://api.github.com/repos/owen-it/laravel-auditing/languages","stargazers_url":"https://api.github.com/repos/owen-it/laravel-auditing/stargazers","contributors_url":"https://api.github.com/repos/owen-it/laravel-auditing/contributors","subscribers_url":"https://api.github.com/repos/owen-it/laravel-auditing/subscribers","subscription_url":"https://api.github.com/repos/owen-it/laravel-auditing/subscription","commits_url":"https://api.github.com/repos/owen-it/laravel-auditing/commits{/sha}","git_commits_url":"https://api.github.com/repos/owen-it/laravel-auditing/git/commits{/sha}","comments_url":"https://api.github.com/repos/owen-it/laravel-auditing/comments{/number}","issue_comment_url":"https://api.github.com/repos/owen-it/laravel-auditing/issues/comments{/number}","contents_url":"https://api.github.com/repos/owen-it/laravel-auditing/contents/{+path}","compare_url":"https://api.github.com/repos/owen-it/laravel-auditing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/owen-it/laravel-auditing/merges","archive_url":"https://api.github.com/repos/owen-it/laravel-auditing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/owen-it/laravel-auditing/downloads","issues_url":"https://api.github.com/repos/owen-it/laravel-auditing/issues{/number}","pulls_url":"https://api.github.com/repos/owen-it/laravel-auditing/pulls{/number}","milestones_url":"https://api.github.com/repos/owen-it/laravel-auditing/milestones{/number}","notifications_url":"https://api.github.com/repos/owen-it/laravel-auditing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/owen-it/laravel-auditing/labels{/name}","releases_url":"https://api.github.com/repos/owen-it/laravel-auditing/releases{/id}","deployments_url":"https://api.github.com/repos/owen-it/laravel-auditing/deployments","created_at":"2015-08-20T11:39:51Z","updated_at":"2017-10-05T12:47:08Z","pushed_at":"2017-10-08T17:04:59Z","git_url":"git://github.com/owen-it/laravel-auditing.git","ssh_url":"git@github.com:owen-it/laravel-auditing.git","clone_url":"https://github.com/owen-it/laravel-auditing.git","svn_url":"https://github.com/owen-it/laravel-auditing","homepage":"http://laravel-auditing.com","size":422,"stargazers_count":641,"watchers_count":641,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":105,"mirror_url":null,"open_issues_count":6,"forks":105,"open_issues":6,"watchers":641,"default_branch":"4.1"}},"_links":{"self":{"href":"https://api.github.com/repos/owen-it/laravel-auditing/pulls/321"},"html":{"href":"https://github.com/owen-it/laravel-auditing/pull/321"},"issue":{"href":"https://api.github.com/repos/owen-it/laravel-auditing/issues/321"},"comments":{"href":"https://api.github.com/repos/owen-it/laravel-auditing/issues/321/comments"},"review_comments":{"href":"https://api.github.com/repos/owen-it/laravel-auditing/pulls/321/comments"},"review_comment":{"href":"https://api.github.com/repos/owen-it/laravel-auditing/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/owen-it/laravel-auditing/pulls/321/commits"},"statuses":{"href":"https://api.github.com/repos/owen-it/laravel-auditing/statuses/23027dfa2e440c5b3ace59ddeede6ef4b28e8dc5"}},"author_association":"NONE"}}
{"actor":{"display_login":"Nitpick-CI"}}