{"id":15764691,"url":"https://github.com/ctf0/odin","last_synced_at":"2025-04-15T14:47:29.645Z","repository":{"id":56959952,"uuid":"109482726","full_name":"ctf0/Odin","owner":"ctf0","description":"manage model revisions with ease","archived":false,"fork":false,"pushed_at":"2023-01-03T23:15:46.000Z","size":100,"stargazers_count":61,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-11T12:19:16.319Z","etag":null,"topics":["diff","javascript","laravel","manager","model","php","revisions","vuejs"],"latest_commit_sha":null,"homepage":"","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/ctf0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"ctf0"}},"created_at":"2017-11-04T09:35:16.000Z","updated_at":"2024-05-17T00:31:46.000Z","dependencies_parsed_at":"2023-02-01T13:02:09.407Z","dependency_job_id":null,"html_url":"https://github.com/ctf0/Odin","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctf0%2FOdin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctf0%2FOdin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctf0%2FOdin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctf0%2FOdin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctf0","download_url":"https://codeload.github.com/ctf0/Odin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249094157,"owners_count":21211825,"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":["diff","javascript","laravel","manager","model","php","revisions","vuejs"],"created_at":"2024-10-04T12:04:26.756Z","updated_at":"2025-04-15T14:47:29.624Z","avatar_url":"https://github.com/ctf0.png","language":"PHP","readme":"\u003ch1 align=\"center\"\u003e\n    Odin\n    \u003cbr\u003e\n    \u003ca href=\"https://packagist.org/packages/ctf0/odin\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/ctf0/odin.svg\" alt=\"Latest Stable Version\" /\u003e\u003c/a\u003e \u003ca href=\"https://packagist.org/packages/ctf0/odin\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/ctf0/odin.svg\" alt=\"Total Downloads\" /\u003e\u003c/a\u003e\n\u003c/h1\u003e\n\nManage model revisions with ease.\n\u003e If you are also looking to preview the form data before submitting to the db, you may want to give [OverSeer](https://github.com/ctf0/OverSeer) a try.\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://user-images.githubusercontent.com/7388088/33775349-be6f1696-dc46-11e7-880f-693a47d86b52.jpg\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/7388088/33775349-be6f1696-dc46-11e7-880f-693a47d86b52.jpg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n- package requires Laravel v5.4+\n\n\u003cbr\u003e\n\n## Installation\n\n- `composer require ctf0/odin`\n\n- (Laravel \u003c 5.5) add the service provider \u0026 facade\n\n    ```php\n    'providers' =\u003e [\n        ctf0\\Odin\\OdinServiceProvider::class,\n    ];\n    ```\n\n* publish the package assets with\n\n    `php artisan vendor:publish --provider=\"ctf0\\Odin\\OdinServiceProvider\"`\n\n- after installation, run `php artisan odin:setup` to add\n    + package routes to `routes/web.php`\n    + package assets compiling to `webpack.mix.js`\n\n- check [laravel-auditing docs](http://www.laravel-auditing.com/docs/master/general-configuration) for configuration\n\n- install dependencies\n\n    ```bash\n    yarn add vue vue-awesome@v2 vue-notif axios keycode\n    ```\n\n- add this one liner to your main js file and run `npm run watch` to compile your `js/css` files.\n    + if you are having issues [Check](https://ctf0.wordpress.com/2017/09/12/laravel-mix-es6/).\n\n    ```js\n    // app.js\n\n    window.Vue = require('vue')\n\n    require('../vendor/Odin/js/manager')\n\n    new Vue({\n        el: '#app'\n    })\n    ```\n\n\u003cbr\u003e\n\n## Features\n\n- support single \u0026 nested values.\n- delete \u0026 restore revisions.\n- support soft deletes.\n- [revision preview](https://github.com/ctf0/Odin/wiki/Preview-Revision).\n- clear audits for permanently deleted models.\n\n    ```bash\n    php artisan odin:gc\n    ```\n\n    + which can be scheduled as well\n      ```php\n      $schedule-\u003ecommand('odin:gc')-\u003esundays();\n      ```\n\n- shortcuts\n\n    |      navigation      |  keyboard  |    mouse (click)    |\n    |----------------------|------------|---------------------|\n    | go to next revision  | right/down | * *(revision date)* |\n    | go to prev revision  | left/up    | * *(revision date)* |\n    | go to first revision | home       | * *(revision date)* |\n    | go to last revision  | end        | * *(revision date)* |\n    | hide revision window | esc        | * *(x)*             |\n\n- events \"[JS](https://github.com/gocanto/vuemit)\"\n\n    | event-name |       description       |\n    |------------|-------------------------|\n    | odin-show   | when revision is showen |\n    | odin-hide   | when revision is hidden |\n\n\u003cbr\u003e\n\n## Usage\n\n- run `php artisan migrate`\n\n- add `Revisions` trait \u0026 `AuditableContract` contract to your model\n    + for `User model` [Check](http://laravel-auditing.com/docs/master/audit-resolvers)\n\n    ```php\n\n    use ctf0\\Odin\\Traits\\Revisions;\n    use Illuminate\\Database\\Eloquent\\Model;\n    use OwenIt\\Auditing\\Contracts\\Auditable as AuditableContract;\n\n    class Post extends Model implements AuditableContract\n    {\n        use Revisions;\n\n        /**\n         * resolve model title/name for the revision relation\n         * this is needed so we can render\n         * the model relation attach/detach changes\n         */\n        public function getMiscTitleAttribute()\n        {\n            return $this-\u003ename;\n        }\n\n        // ...\n    }\n    ```\n\n- you can disable creating **ghost** audits where both `old/new` values are empty by using\n    + remember that without the parent model audit log we cant show the relation changes\n\n    ```php\n    // app/Providers/EventServiceProvider\n\n    use OwenIt\\Auditing\\Models\\Audit;\n\n    public function boot()\n    {\n        parent::boot();\n\n        Audit::creating(function (Audit $model) {\n            if (empty($model-\u003eold_values) \u0026\u0026 empty($model-\u003enew_values)) {\n                return false;\n            }\n        });\n    }\n    ```\n\n- inside the model view ex.`post edit view` add\n\n    ```blade\n    @if (count($post-\u003erevisionsWithRelation))\n        @include('Odin::list', ['revisions' =\u003e $post-\u003erevisionsWithRelation])\n    @endif\n    ```\n\n\u003cbr\u003e\n\n## Notes\n\n- model `user_id` \u0026 `id` are excluded from the audit log by default.\n\n- **data:uri**\n    - if you use `data:uri` in your revisionable content, change [`audits_table`](https://github.com/owen-it/laravel-auditing/blob/958a6edd4cd4f9d61aa34f288f708644e150e866/database/migrations/audits.stub#L33-L34) columns type to either `mediumText` or `longText` before migrating to avoid future errors of long data.\n\n    - because `data:uri` is a render blocking \u0026 isn't readable by humans, we truncate it to 75 char max\u003cbr\u003e\n        note that this ***ONLY*** effects the displaying of the revision diff, we never touch the data that gets saved to the db.\n\n- **model-relation**\n    + atm the relation revision is limited, it means we can only show the `attach/detach` changes but we cant `undo/redo` any of them through the package it self.\n    + also if you use mass update like `Model::update()` make sure to call `$model-\u003etouch();` afterwards to make sure an audit is created ex.\n        ```php\n        $model = Model::update([...]);\n        $model-\u003etouch();\n        ```\n\n\u003cbr\u003e\n\n### Security\n\nIf you discover any security-related issues, please email [ctf0-dev@protonmail.com](mailto:ctf0-dev@protonmail.com).\n","funding_links":["https://github.com/sponsors/ctf0"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctf0%2Fodin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctf0%2Fodin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctf0%2Fodin/lists"}