{"id":22615931,"url":"https://github.com/hexadog/laravel-auditable","last_synced_at":"2025-03-29T00:43:12.563Z","repository":{"id":43680849,"uuid":"366825998","full_name":"hexadog/laravel-auditable","owner":"hexadog","description":"Know who manipulates your models in your Laravel application.","archived":false,"fork":false,"pushed_at":"2023-10-23T13:43:36.000Z","size":200,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-03-25T03:46:04.225Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hexadog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2021-05-12T19:07:45.000Z","updated_at":"2024-03-25T03:46:04.226Z","dependencies_parsed_at":"2022-09-02T16:49:37.318Z","dependency_job_id":"93e5856d-c030-4ceb-913e-e55f360a2247","html_url":"https://github.com/hexadog/laravel-auditable","commit_stats":{"total_commits":16,"total_committers":3,"mean_commits":5.333333333333333,"dds":0.5625,"last_synced_commit":"1041cd44084698248f0a86359681145ddd8d1c41"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexadog%2Flaravel-auditable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexadog%2Flaravel-auditable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexadog%2Flaravel-auditable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexadog%2Flaravel-auditable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexadog","download_url":"https://codeload.github.com/hexadog/laravel-auditable/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246122245,"owners_count":20726822,"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":[],"created_at":"2024-12-08T19:10:09.170Z","updated_at":"2025-03-29T00:43:12.525Z","avatar_url":"https://github.com/hexadog.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Package Logo](https://banners.beyondco.de/Auditable.png?theme=light\u0026packageManager=composer+require\u0026packageName=hexadog%2Flaravel-auditable\u0026pattern=architect\u0026style=style_1\u0026description=Know+who+manipulates+your+models+in+your+Laravel+application\u0026md=1\u0026showWatermark=1\u0026fontSize=100px\u0026images=identification)\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/hexadog/laravel-auditable\"\u003e\n        \u003cimg src=\"https://poser.pugx.org/hexadog/laravel-auditable/v\" alt=\"Latest Stable Version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/hexadog/laravel-auditable\"\u003e\n        \u003cimg src=\"https://poser.pugx.org/hexadog/laravel-auditable/downloads\" alt=\"Total Downloads\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/hexadog/laravel-auditable\"\u003e\n        \u003cimg src=\"https://poser.pugx.org/hexadog/laravel-auditable/license\" alt=\"License\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003ccode\u003ehexadog/laravel-auditable\u003c/code\u003e helps you to automatically register the user making action on your models.\n\n\u003c!-- omit in toc --\u003e\n## Installation\nThis package requires PHP 7.3 and Laravel 7.0 or higher.\n\nTo get started, install Auditable using Composer:\n```shell\ncomposer require hexadog/laravel-auditable\n```\n\nThe package will automatically register its service provider.\n\n## Usage\nUse the new `auditable` macro into your migrations.\n```php\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Facades\\Schema;\n\nSchema::table('posts', function (Blueprint $table) {\n    $table-\u003eauditable();\n});\n\nSchema::table('posts', function (Blueprint $table) {\n    $table-\u003edropAuditable();\n});\n```\n\nIt will add the following columns:\n- created_at\n- created_by\n- updated_at\n- updated_by\n- deleted_at\n- deleted_by\n\n**Notice:** You don't have to use `timestamps()` nor `sofDeletes()` macros. Auditable macro will integrate them for you.\n\n_If you altered you DB and want to drop auditable columns you can use the macro `$table-\u003edropAuditable()`;_\n\nOnce database has been migrated you can use the `Auditable` trait into your model.\n\n```php\nuse Hexadog\\Auditable\\Models\\Traits\\Auditable;\n\nclass Post extends Models\n{\n    use Auditable;\n\n    // ...\n}\n```\n\nThis way the id of the user responsible of the action (creation, update, soft deletion) is automatically registered into your model in the associated column each time the data is touched. You don't have to do anything.\n\n## Retreive user responsible of the action\nYou can retreive the user respoinsible of the last action (create, update, delete) by calling one of the helper methods provided by the trait.\n\nTo determine the user responsible of the model creation you may use the `created_by` attribute to get the id or the `createdBy` relation to get the target model:\n```php\n// Get user responsible of the creation of the post\n$post-\u003ecreatedBy;\n\n// Get the creation date\n$post-\u003ecreated_at;\n```\n\nTo determine the user responsible of the last model update you may use the `updated_by` attribute to get the id or the `updatedBy` relation to get the target model:\n```php\n// Get user responsible of the last update of the post\n$post-\u003eupdatedBy;\n\n// Get the last update date\n$post-\u003eupdated_at;\n```\n\nTo determine the user responsible of the model deletion (only if the model uses `SoftDeletes` trait) you may use the `deleted_by` attribute to get the id or the `deletedBy` relation to get the target model:\n```php\n// Get user responsible of the post deletion (ONLY if soft deletes are used)\n$post-\u003edeletedBy;\n\n// Get the soft deletion date\n$post-\u003edeleted_at;\n```\n\n\u003c!-- omit in toc --\u003e\n## Credits\n- Logo made by [BeyondCode](https://banners.beyondco.de/)\n\n\u003c!-- omit in toc --\u003e\n## License\nLaravel Auditable is open-sourced software licensed under the [MIT license](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexadog%2Flaravel-auditable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexadog%2Flaravel-auditable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexadog%2Flaravel-auditable/lists"}