{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/ideas/issues/893","repository_url":"https://api.github.com/repos/laravel/ideas","labels_url":"https://api.github.com/repos/laravel/ideas/issues/893/labels{/name}","comments_url":"https://api.github.com/repos/laravel/ideas/issues/893/comments","events_url":"https://api.github.com/repos/laravel/ideas/issues/893/events","html_url":"https://github.com/laravel/ideas/issues/893","id":275515689,"number":893,"title":"[Proposal] Optional Event Tracking ","user":{"login":"ibourgeois","id":3633464,"avatar_url":"https://avatars1.githubusercontent.com/u/3633464?v=4","gravatar_id":"","url":"https://api.github.com/users/ibourgeois","html_url":"https://github.com/ibourgeois","followers_url":"https://api.github.com/users/ibourgeois/followers","following_url":"https://api.github.com/users/ibourgeois/following{/other_user}","gists_url":"https://api.github.com/users/ibourgeois/gists{/gist_id}","starred_url":"https://api.github.com/users/ibourgeois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibourgeois/subscriptions","organizations_url":"https://api.github.com/users/ibourgeois/orgs","repos_url":"https://api.github.com/users/ibourgeois/repos","events_url":"https://api.github.com/users/ibourgeois/events{/privacy}","received_events_url":"https://api.github.com/users/ibourgeois/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-11-20T22:07:54Z","updated_at":"2018-03-17T18:48:30Z","closed_at":"2018-03-17T18:48:30Z","author_association":"NONE","body":"I am prepared to create a PR if it's okay, but what about an event tracking system that is opt in?\r\n\r\nIf tracking is enabled in the config, then in the Request class (if `$request->user()` is set) and provided the controller is RESTful then using `$request->route()->action['controller']` we can generate event actions like \"`$user viewed $item`\" if index() is fired or \"`$user edited $item`\" when update() is fired. In the case of non-RESTful methods or need for customer action message then call the method directly and pass in the message `$request->track(\"Custom action method here...\")` before redirecting/returning.\r\n\r\nMy thoughts would be no UI. just a migration for tracking...\r\n```php\r\nSchema::create('tracking', function (Blueprint $table) {\r\n        $table->increments('id');\r\n        $table->integer('user_id')->unsigned();\r\n        $table->string('action');\r\n        $table->timestamps();\r\n\r\n        $table->foreign('user_id')\r\n                ->references('id')\r\n                ->on('users')\r\n                ->onDelete('cascade');\r\n});\r\n```\r\n\r\nThis could be implemented several ways, from middleware to adding a `track()` method to Route to enable tracking for certain methods: `Route::resource('/', 'SomeController')->track(['index', 'edit']);`, a config file that lists controllers to be tracked explicitly, and of course requiring the track() method to be called in the controller method or constructor to enable tracking.\r\n\r\nI was planning on creating this as a package, but curious if a PR would be an option first? "},"comment":{"url":"https://api.github.com/repos/laravel/ideas/issues/comments/373943572","html_url":"https://github.com/laravel/ideas/issues/893#issuecomment-373943572","issue_url":"https://api.github.com/repos/laravel/ideas/issues/893","id":373943572,"user":{"login":"taylorotwell","id":463230,"avatar_url":"https://avatars3.githubusercontent.com/u/463230?v=4","gravatar_id":"","url":"https://api.github.com/users/taylorotwell","html_url":"https://github.com/taylorotwell","followers_url":"https://api.github.com/users/taylorotwell/followers","following_url":"https://api.github.com/users/taylorotwell/following{/other_user}","gists_url":"https://api.github.com/users/taylorotwell/gists{/gist_id}","starred_url":"https://api.github.com/users/taylorotwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taylorotwell/subscriptions","organizations_url":"https://api.github.com/users/taylorotwell/orgs","repos_url":"https://api.github.com/users/taylorotwell/repos","events_url":"https://api.github.com/users/taylorotwell/events{/privacy}","received_events_url":"https://api.github.com/users/taylorotwell/received_events","type":"User","site_admin":false},"created_at":"2018-03-17T18:48:30Z","updated_at":"2018-03-17T18:48:30Z","author_association":"OWNER","body":"Would rather see this as a package."}}
{"actor":{"display_login":"taylorotwell"}}