{"id":13606652,"url":"https://github.com/LukeTowers/wn-easyaudit-plugin","last_synced_at":"2025-04-12T08:31:49.189Z","repository":{"id":50291160,"uuid":"89764649","full_name":"LukeTowers/wn-easyaudit-plugin","owner":"LukeTowers","description":" Easily view and manage audit logs for models within your Winter CMS projects.","archived":false,"fork":false,"pushed_at":"2024-05-22T20:24:17.000Z","size":144,"stargazers_count":17,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-23T01:17:24.247Z","etag":null,"topics":["activity-log","activity-log-laravel","activity-logger","laravel","php","wintercms","wintercms-plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LukeTowers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-29T04:57:07.000Z","updated_at":"2024-06-10T04:47:41.654Z","dependencies_parsed_at":"2024-06-10T04:47:35.614Z","dependency_job_id":null,"html_url":"https://github.com/LukeTowers/wn-easyaudit-plugin","commit_stats":{"total_commits":52,"total_committers":4,"mean_commits":13.0,"dds":"0.21153846153846156","last_synced_commit":"e45f8939fad0c8305470913f2b6a7954793b8753"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeTowers%2Fwn-easyaudit-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeTowers%2Fwn-easyaudit-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeTowers%2Fwn-easyaudit-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeTowers%2Fwn-easyaudit-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LukeTowers","download_url":"https://codeload.github.com/LukeTowers/wn-easyaudit-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248539966,"owners_count":21121265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activity-log","activity-log-laravel","activity-logger","laravel","php","wintercms","wintercms-plugin"],"created_at":"2024-08-01T19:01:11.124Z","updated_at":"2025-04-12T08:31:44.181Z","avatar_url":"https://github.com/LukeTowers.png","language":"PHP","funding_links":["https://paypal.me/theluketowers/30USD"],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# About\n\nEasily view and manage audit logs for models within your Winter CMS projects.\n\n# Installation\n\nThis plugin requires a [paid license ($30 USD)](https://paypal.me/theluketowers/30USD).\n\nTo install it with Composer, run `composer require luketowers/wn-easyaudit-plugin` from your project root.\n\n# Documentation\n\nTo get started using this plugin just add the `TrackableModel` Behavior to any models that you wish to track:\n\n```php\nclass MyModel extends Model\n{\n    /**\n     * @var array Behaviors implemented by this model class\n     */\n    public $implement = ['@LukeTowers.EasyAudit.Behaviors.TrackableModel'];\n}\n```\n\nOnce you've added the `TrackableModel` behavior to a model, any local events fired on the model that have been set up in `$trackableEvents` will be automatically listened to and an audit record will be generated for each event.\n\nBy default, the `TrackableModel` behavior will listen to the following events:\n\n- `model.afterCreate`\n- `model.afterUpdate`\n- `model.afterDelete`\n\nIn addition to the properties above, you can also add the following properties to model classes to configure the audit logging behavior:\n\n```php\nclass MyModel extends Model\n{\n    // ...\n\n    /**\n     * @var array The model events that are to be tracked as activities\n     */\n    public $trackableEvents = [\n        'model.afterCreate' =\u003e ['name' =\u003e 'created', 'description' =\u003e 'The record was created'],\n        'model.afterUpdate' =\u003e ['name' =\u003e 'updated', 'description' =\u003e 'The record was updated'],\n        'model.afterDelete' =\u003e ['name' =\u003e 'archived', 'description' =\u003e 'The record was archived'],\n    ];\n\n    /**\n     * @var bool Manually control the IP address logging on this model (default from the luketowers.easyaudit.logIpAddress config setting)\n     */\n    public $trackableLogIpAddress = true;\n\n    /**\n     * @var bool Manually control the User agent logging on this model (default from the luketowers.easyaudit.logUserAgent config setting)\n     */\n    public $trackableLogUserAgent = true;\n\n    /**\n     * @var bool Manually control the change tracking on this model (default from the luketowers.easyaudit.trackChanges config setting)\n     */\n    public $trackableTrackChanges = true;\n\n    /**\n     * @var bool Manually control if the activities field gets automatically injected into backend forms\n     * for this model (default from the luketowers.easyaudit.autoInjectActvitiesFormWidget config setting)\n     */\n    public $trackableInjectActvitiesFormWidget = true;\n}\n```\n\nYou can view a model's audit log by adding a field targeting the `activities` relationship (added by the `TrackableModel` behavior) with the type of `activitylog` to the relevant `fields.yaml` files:\n\n```php\nactivities:\n    tab: Audit Log\n    context: [update, preview]\n    type: activitylog\n    span: full\n```\n\n# Advanced Usage\n\nIt is also possible to log events directly using the `LukeTowers\\EasyAudit\\Classes\\ActivityLogger` class:\n\nTo use, create a new instance of this class and then either chain the methods for the data as required or call the `log()` method directly.\nExample (all in one):\n\n```php\n$activity = new ActivityLogger();\n$activity-\u003elog('updated', 'MyModel updated', $myModel, BackendAuth::getUser(), ['maintenanceMode' =\u003e true], 'MyVendor.MyPlugin');\n```\n\nOr (chained):\n\n```php\n$activity = new ActivityLogger();\n$activity-\u003einLog('MyVendor.MyPlugin')\n        -\u003efor($myModel)\n        -\u003eby(BackendAuth::getUser())\n        -\u003edescription('MyModel updated')\n        -\u003eproperties(['maintenanceMode' =\u003e true])\n        -\u003elog('updated');\n```\n\nAdditionally, the ActivityLogger() class is available on models implementing the `LukeTowers.EasyAudit.Behaviors.TrackableModel` behavior through the `activity()` method.\nThis enables you to do the following:\n\n```php\nclass Asset extends Model\n{\n    // ...\n\n    public function updateInventory()\n    {\n        // ...\n        $this-\u003eactivity('updated_inventory')-\u003edescription(\"The asset's inventory was updated\")-\u003elog();\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLukeTowers%2Fwn-easyaudit-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLukeTowers%2Fwn-easyaudit-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLukeTowers%2Fwn-easyaudit-plugin/lists"}