{"id":21598118,"url":"https://github.com/matfish2/eloquent-logger","last_synced_at":"2025-04-11T01:01:52.369Z","repository":{"id":62505057,"uuid":"50734852","full_name":"matfish2/eloquent-logger","owner":"matfish2","description":"Log Eloquent model changes to a designated logs table","archived":false,"fork":false,"pushed_at":"2017-11-08T17:09:53.000Z","size":19,"stargazers_count":9,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-23T15:22:42.995Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/fish/eloquent-logger","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/matfish2.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}},"created_at":"2016-01-30T17:07:17.000Z","updated_at":"2019-05-21T11:23:44.000Z","dependencies_parsed_at":"2022-11-02T10:01:29.094Z","dependency_job_id":null,"html_url":"https://github.com/matfish2/eloquent-logger","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matfish2%2Feloquent-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matfish2%2Feloquent-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matfish2%2Feloquent-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matfish2%2Feloquent-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matfish2","download_url":"https://codeload.github.com/matfish2/eloquent-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322600,"owners_count":21084336,"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-11-24T18:11:20.398Z","updated_at":"2025-04-11T01:01:52.333Z","avatar_url":"https://github.com/matfish2.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eloquent Logger\n[![Latest Stable Version](https://poser.pugx.org/fish/eloquent-logger/v/stable)](https://packagist.org/packages/fish/eloquent-logger) [![Total Downloads](https://poser.pugx.org/fish/eloquent-logger/downloads)](https://packagist.org/packages/fish/eloquent-logger) [![Latest Unstable Version](https://poser.pugx.org/fish/eloquent-logger/v/unstable)](https://packagist.org/packages/fish/eloquent-logger) [![License](https://poser.pugx.org/fish/eloquent-logger/license)](https://packagist.org/packages/fish/eloquent-logger)\n\nThis Laravel 5 package adds logging functionality to Eloquent models. All changes (create, update, delete) will be recorded in a designated logs table.\nUpdates will record only dirty fields.\n\n## Installation\n\nAdd to `composer.json`:\n\n    \"require\": {\n      \"fish/eloquent-logger\": \"^1.0\"\n    }\n\nUpdate Composer from the Terminal:\n\n    composer update\n\nAdd the service provider to the the list of providers in your `app.php`\n\n    Fish\\Logger\\LoggerServiceProvider\n\nPublish migration:\n\n    php artisan logger:init\n\nRun migration:\n\n    php artisan migrate\n\n## Usage\n\nUse the trait on relevant models. E.g:\n\n    namespace App;\n\n    use Illuminate\\Database\\Eloquent\\Model;\n    use Fish\\Logger\\Logger;\n\n    class Post extends Model\n    {\n      use Logger;\n    }\n\nRetrieving logs for a model:\n\n    Post::find(1)-\u003elogs\n\nRetrieving model from log (if the action was not `deleted`):\n\n    Fish\\Logger\\Log::find(1)-\u003eloggable;\n\nRetrieve the state of the model at a certain point of time:\n\n    Post::find(1)-\u003elogs()-\u003estateOn('2015-02-02 13:00:00');\n\nTo retrieve the state of a deleted model:\n\n    Fish\\Logger\\Log::entity(Post::class, 1)-\u003estateOn('2016-01-01 12:00:00');\n\nThe model will be retrieved even if the passed timestamp occured after it was already deleted.\n\nThe Log contains the following properties:\n\n* `user_id` `integer`: User who did the action. if there is no authenticated user, set to `null`\n* `action` `string`: type of action - `created`, `updated` or `deleted`\n* `before` `array`: state of the model before the action. If the action is `created` set to `null`\n* `after` `array`: state of the model after the action. If the action is `deleted` set to `null`\n* `created_at` `datetime`: action's timestamp\n\n### Query helpers\n\n* `wasCreated`, `wasUpdated` or `wasDeleted` - filter by action.\n* `between` - filter by date range.\n\nExample:\n\n    Post::find(1)-\u003elogs()\n                -\u003ewasUpdated()\n                -\u003ebetween('2015-01-01','2015-02-01')\n                -\u003eget();\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatfish2%2Feloquent-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatfish2%2Feloquent-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatfish2%2Feloquent-logger/lists"}