├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── feature_request.md ├── ci-reporter.yml ├── config.yml ├── pull_request_template.md ├── release-drafter.yml ├── stale.yml ├── support.yml └── workflows │ └── add-to-project.yml ├── .styleci.yml ├── changelog.md ├── composer.json ├── contributing.md ├── license.md ├── readme.md ├── resources ├── lang │ ├── ar │ │ └── revise.php │ ├── bg │ │ └── revise.php │ ├── cs │ │ └── revise.php │ ├── da-DK │ │ └── revise.php │ ├── da_DK │ │ └── revise.php │ ├── de │ │ └── revise.php │ ├── el │ │ └── revise.php │ ├── en │ │ └── revise.php │ ├── es │ │ └── revise.php │ ├── fa │ │ └── revise.php │ ├── fr-CA │ │ └── revise.php │ ├── fr │ │ └── revise.php │ ├── fr_CA │ │ └── revise.php │ ├── id │ │ └── revise.php │ ├── it │ │ └── revise.php │ ├── ja │ │ └── revise.php │ ├── lv │ │ └── revise.php │ ├── nl │ │ └── revise.php │ ├── pt-BR │ │ └── revise.php │ ├── pt │ │ └── revise.php │ ├── pt_BR │ │ └── revise.php │ ├── ro │ │ └── revise.php │ ├── ru │ │ └── revise.php │ ├── sr │ │ └── revise.php │ ├── tr │ │ └── revise.php │ ├── uk │ │ └── revise.php │ ├── zh-Hant │ │ └── revise.php │ └── zh-cn │ │ └── revise.php └── views │ ├── revise_button.blade.php │ ├── revision_timeline.blade.php │ └── revisions.blade.php └── src ├── ReviseOperation.php └── ReviseOperationServiceProvider.php /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[Bug] " 5 | labels: Bug 6 | assignees: pxpm 7 | 8 | --- 9 | 10 | # Bug report 11 | 12 | ### What I did 13 | 14 | ?? 15 | 16 | ### What I expected to happen 17 | 18 | ?? 19 | 20 | ### What happened 21 | 22 | ?? 23 | 24 | ### What I've already tried to fix it 25 | 26 | ?? 27 | 28 | ### Backpack, Laravel, PHP, DB version 29 | 30 | When I run ```php artisan backpack:version``` the output is: 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Documentation issue 4 | url: https://github.com/laravel-backpack/docs 5 | about: For documentation issues, open an issue or pull request in our docs repository. 6 | - name: Help & support 7 | url: https://stackoverflow.com/questions/tagged/backpack-for-laravel 8 | about: Backpack doesn't offer official support - only community support. Please post your question & code on StackOverflow, using the backpack-for-laravel tag. We've been blessed with a great community, that is happy to help. 9 | - name: Quick question 10 | url: https://gitter.im/BackpackForLaravel/Lobby 11 | about: If you have an urgent matter that won't take much time to answer, use our 24/7 Gitter chatroom. Tens of people hang out there sometimes. But keep in mind chatrooms are NOT a good place to post code, or ask for anything more than a quick answer. 12 | - name: Miscellaneous 13 | url: https://www.reddit.com/r/BackpackForLaravel/ 14 | about: If you just want to bounce ideas off someone, share something you've made, or talk about Backpack, Laravel or web development in general - join our subreddit. -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[Feature Request]" 5 | labels: Feature Request 6 | assignees: pxpm, tabacitu 7 | 8 | --- 9 | 10 | # Feature Request 11 | 12 | ### What's the feature you think this package should have? 13 | 14 | ?? 15 | 16 | ### Have you already implemented a prototype solution, for your own project? 17 | 18 | ?? 19 | 20 | ### Do you see this as a core feature or an add-on? 21 | 22 | ?? 23 | -------------------------------------------------------------------------------- /.github/ci-reporter.yml: -------------------------------------------------------------------------------- 1 | # Set to false to create a new comment instead of updating the app's first one 2 | updateComment: false 3 | 4 | # Use a custom string, or set to false to disable 5 | before: "✨ Good work on this PR so far! ✨ Unfortunately, the [ build]() is failing as of . Here's the output:" 6 | 7 | # Use a custom string, or set to false to disable 8 | after: "I'm sure you can fix it! If you need help, don't hesitate to ask a maintainer of the project!" -------------------------------------------------------------------------------- /.github/config.yml: -------------------------------------------------------------------------------- 1 | # Configuration for welcome - https://github.com/behaviorbot/welcome 2 | 3 | # Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome 4 | 5 | # Comment to be posted to on first time issues 6 | newIssueWelcomeComment: > 7 | Hello there! Thanks for opening your first issue on this repo! 8 | 9 | 10 | Just a heads-up: **Here at Backpack we use Github Issues only for tracking bugs**. Talk about new features is also acceptable. This helps _a lot_ in keeping our focus on improving Backpack. **If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below)**. If you're not sure where it fits, it's ok, a community member will probably reply to help you with that. 11 | 12 | 13 | Backpack communication channels: 14 | - Bug Reports, Feature Requests - Github Issues (here); 15 | - Quick help (_How do I do X_) - [Gitter Chatroom](https://gitter.im/BackpackForLaravel/Lobby); 16 | - Long questions (_I have done X and Y and it won't do Z wtf_) - [Stackoverflow](https://stackoverflow.com/questions/tagged/backpack-for-laravel), using the ```backpack-for-laravel``` tag; 17 | - Showing off something you've made, asking for opinion on Backpack/Laravel matters - [Reddit](https://www.reddit.com/r/BackpackForLaravel/); 18 | 19 | Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome _awesome_ community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch. 20 | 21 | 22 | Thank you! 23 | 24 | 25 | -- 26 | 27 | Justin Case 28 | 29 | The Backpack Robot 30 | 31 | # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome 32 | 33 | # Comment to be posted to on PRs from first time contributors in your repository 34 | newPRWelcomeComment: > 35 | BOOM! Your first PR with us, thank you so much! Someone will take a look at it shortly. 36 | 37 | 38 | Please keep in mind that: 39 | - **if this constitutes a breaking change, it might take quite a while for this to get merged**; we try to emulate the Laravel release cycle as much as possible, so developers can upgrade both software once; this means a new big release every ~6 months; 40 | - **even if it's a non-breaking change, it might take a few days/weeks for the PR to get merged**; unless it's a no-brainer, **we like to have some community feedback on new features, before we merge them**; this leads to higher-quality code, in the end; we learnt this the hard way :-) 41 | - **not all PRs get merged**; sometimes we just have to hold out new features, to keep the packages lean; sometimes we don't include features that only apply to niche use cases; 42 | - **we're not perfect**; if you think we're wrong, call us out on it; but in a kind way :-) we all make mistakes, best we learn from them and build better software together; 43 | 44 | 45 | Thank you! 46 | 47 | 48 | -- 49 | 50 | Justin Case 51 | 52 | The Backpack Robot 53 | 54 | # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge 55 | 56 | # Comment to be posted to on pull requests merged by a first time user 57 | firstPRMergeComment: > 58 | WHOOP-WHOOP! Congrats, your first PR on this repo has officialy been merged. 59 | 60 | 61 | ![party](https://media1.giphy.com/media/3KC2jD2QcBOSc/giphy.gif "Party!!!") 62 | 63 | 64 | 65 | You should also receive an email inviting you to [the Community Members team](https://github.com/orgs/Laravel-Backpack/teams/community-members). That's where we, commited community members, debate new features and decide what's in the Backpack roadmap. Feel free to ignore the invitation if you're not interested :-) 66 | 67 | 68 | If you want to help out the community in other ways, you can: 69 | - **give your opinion on other Github Issues & PRs**; 70 | - **chat with others** in the [Gitter Chatroom](https://gitter.im/BackpackForLaravel/Lobby) (usually for quick help: _How do I do X_); 71 | - **answer Backpack questions on [Stackoverflow](https://stackoverflow.com/questions/tagged/backpack-for-laravel)**; you get points, people get help; you can subscribe to the ```backpack-for-laravel``` tag by [adding a new filter](https://stackexchange.com/filters/256210/my-filter-3); that will send you emails when new questions come up with our tag; 72 | 73 | 74 | Again. Thank you for the PR. You are a wonderful person. Keep 'em coming :-) 75 | 76 | Cheers! 77 | 78 | 79 | -- 80 | 81 | Justin Case 82 | 83 | The Backpack Robot 84 | 85 | 86 | # It is recommend to include as many gifs and emojis as possible 87 | # 88 | # --------------------------------------------------------------------------------------------- 89 | # 90 | # Configuration for request-info - https://github.com/behaviorbot/request-info 91 | 92 | # *OPTIONAL* Comment to reply with 93 | # Can be either a string : 94 | requestInfoReplyComment: > 95 | Hi there! 96 | 97 | 98 | Could you please provide us with more info about this? Looks like you skipped the title/body. 99 | 100 | 101 | Thank you! 102 | 103 | 104 | -- 105 | 106 | Justin Case 107 | 108 | The Backpack Robot 109 | 110 | # Or an array: 111 | # requestInfoReplyComment: 112 | # - Ah no! young blade! That was a trifle short! 113 | # - Tell me more ! 114 | # - I am sure you can be more effusive 115 | 116 | 117 | # *OPTIONAL* default titles to check against for lack of descriptiveness 118 | # MUST BE ALL LOWERCASE 119 | requestInfoDefaultTitles: 120 | # - update readme.md 121 | - updates 122 | 123 | # *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given 124 | requestInfoLabelToAdd: needs-more-info 125 | 126 | # *OPTIONAL* Only warn about insufficient information on these events type 127 | # Keys must be lowercase. Valid values are 'issue' and 'pullRequest' 128 | requestInfoOn: 129 | pullRequest: true 130 | issue: true 131 | 132 | # *OPTIONAL* Add a list of people whose Issues/PRs will not be commented on 133 | # keys must be GitHub usernames 134 | requestInfoUserstoExclude: 135 | - tabacitu 136 | 137 | # --------------------------------------------------------------------------------------------- 138 | # 139 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## WHY 2 | 3 | ### BEFORE - What was wrong? What was happening before this PR? 4 | 5 | ?? 6 | 7 | ### AFTER - What is happening after this PR? 8 | 9 | ?? 10 | 11 | 12 | ## HOW 13 | 14 | ### How did you achieve that, in technical terms? 15 | 16 | ?? 17 | 18 | 19 | 20 | ### Is it a breaking change or non-breaking change? 21 | 22 | ?? 23 | 24 | 25 | ### How can we test the before & after? 26 | 27 | ?? 28 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | # branches to consider in the event; optional, defaults to all 6 | branches: 7 | - master 8 | 9 | jobs: 10 | update_release_draft: 11 | runs-on: ubuntu-latest 12 | steps: 13 | # Drafts your next Release notes as Pull Requests are merged into "master" 14 | - uses: release-drafter/release-drafter@v5 15 | env: 16 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 17 | 18 | name-template: '$NEXT_PATCH_VERSION 🌈' 19 | tag-template: '$NEXT_PATCH_VERSION' 20 | categories: 21 | - title: '🚀 Features' 22 | labels: 23 | - 'feature' 24 | - 'enhancement' 25 | - 'added' 26 | - title: '🐛 Bug Fixes' 27 | labels: 28 | - 'fix' 29 | - 'bugfix' 30 | - 'bug' 31 | - 'fixed' 32 | - title: '⚙️ Changes' 33 | labels: 34 | - 'changed' 35 | - 'dependencies' 36 | - title: '🧰 Removed' 37 | label: 'removed' 38 | change-template: '- $TITLE @$AUTHOR (#$NUMBER)' 39 | template: | 40 | ## Changes 41 | 42 | $CHANGES 43 | 44 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | ##################################### 2 | # Github Stale Probot Configuration # 3 | # ################################### 4 | # https://probot.github.io/apps/stale/ 5 | 6 | # Number of days of inactivity before an issue becomes stale 7 | daysUntilStale: 60 8 | # Number of days of inactivity before a stale issue is closed 9 | daysUntilClose: 14 10 | # Issues with these labels will never be considered stale 11 | exemptLabels: 12 | - pinned 13 | - security 14 | - feature 15 | - urgent 16 | - ready 17 | - working on it 18 | - bug 19 | 20 | # Label to use when marking an issue as stale 21 | staleLabel: stale 22 | # Comment to post when marking an issue as stale. Set to `false` to disable 23 | markComment: > 24 | Hi there! 25 | 26 | 27 | **Is this still an issue?** No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it. 28 | 29 | 30 | Thank you! 31 | 32 | 33 | -- 34 | 35 | Justin Case 36 | 37 | The Backpack Robot 38 | 39 | # Comment to post when closing a stale issue. Set to `false` to disable 40 | closeComment: true 41 | -------------------------------------------------------------------------------- /.github/support.yml: -------------------------------------------------------------------------------- 1 | # Configuration for support-requests - https://github.com/dessant/support-requests 2 | 3 | # Label used to mark issues as support requests 4 | supportLabel: Ask-It-On-Stack-Overflow 5 | # Comment to post on issues marked as support requests. Add a link 6 | # to a support page, or set to `false` to disable 7 | supportComment: > 8 | Oups! 9 | 10 | 11 | Looks like this is a support request, not a bug/feature. **Could you please [repost on StackOverflow](https://stackoverflow.com/questions/tagged/backpack-for-laravel), using the ```backpack-for-laravel``` tag**? 12 | 13 | 14 | Background: **Here at Backpack we use Github Issues only for tracking bugs and features**, not individual implementation issues. This helps _a lot_ in keeping our focus on improving Backpack. Thanks a lot for understanding! 15 | 16 | 17 | Here are all the Backpack communication mediums: 18 | - Long questions (_I have done X and Y and it won't do Z wtf_) - [Stackoverflow](https://stackoverflow.com/questions/tagged/backpack-for-laravel), using the ```backpack-for-laravel``` tag; this is recommended for most questions, since other developers can then find the answer on a simple Google search; also, people get points for answering - and who doesn't like StackOverflow points?! 19 | - Quick help (_How do I do X_) - [Gitter Chatroom](https://gitter.im/BackpackForLaravel/Lobby); 20 | - Bug Reports, Feature Requests - Github Issues (here); 21 | 22 | Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or StackOverflow is thanks to our awesome _awesome_ community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch. 23 | 24 | 25 | Thank you! 26 | 27 | 28 | -- 29 | 30 | Justin Case 31 | 32 | The Backpack Robot 33 | 34 | 35 | PS. In case I mistakenly closed your issue, yell :-) I'm a robot, I make mistakes. 36 | 37 | # Whether to close issues marked as support requests 38 | close: true 39 | # Whether to lock issues marked as support requests 40 | lock: false 41 | -------------------------------------------------------------------------------- /.github/workflows/add-to-project.yml: -------------------------------------------------------------------------------- 1 | name: Add new bugs & PRs to This Week project 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | - transferred 8 | pull_request: 9 | types: 10 | - opened 11 | 12 | jobs: 13 | add-to-project: 14 | name: Add new bugs and PRs to This Week project 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/add-to-project@main 18 | with: 19 | project-url: https://github.com/orgs/Laravel-Backpack/projects/13 20 | github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} 21 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | preset: laravel -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `ReviseOperation` will be documented in this file. 4 | 5 | 6 | ## Version 1.0.4 - 2020-07-22 7 | 8 | ### Added 9 | - ability to overwrite operation views - fixes #4; 10 | 11 | ## Version 1.0.3 - 2020-07-03 12 | 13 | ### Fixed 14 | - Fix revisions list not updating after Undo @tabacitu (#3) 15 | 16 | ## Version 1.0.2 - 2020-03-27 17 | 18 | ### Fixed 19 | - main view extends "blank" layout instead of "top_left" so that CSS works inside widgets; 20 | 21 | ## Version 1.0.1 - 2020-03-21 22 | 23 | ### Added 24 | - Support for Backpack 4.1; 25 | 26 | 27 | ## Version 1.0.0 - 2020-03-21 28 | 29 | ### Added 30 | - Everything 31 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "backpack/revise-operation", 3 | "description": "Backpack interface for venturecraft/revisionable", 4 | "license": "MIT", 5 | "authors": [ 6 | { 7 | "name": "Cristian Tabacitu", 8 | "email": "tabacitu@backpackforlaravel.com", 9 | "homepage": "https://backpackforlaravel.com" 10 | } 11 | ], 12 | "homepage": "https://github.com/laravel-backpack/revise-operation", 13 | "keywords": [ 14 | "Laravel", "ReviseOperation", "Backpack", "Backpack for Laravel", "Backpack Operation", 15 | "Backpack Add-On", "Admin Panel", "Admin Interface", "Revision History", "Audit Log", 16 | "Revisionable", "Revisions" 17 | ], 18 | "require": { 19 | "backpack/crud": "^6.0", 20 | "venturecraft/revisionable": "1.*" 21 | }, 22 | "autoload": { 23 | "psr-4": { 24 | "Backpack\\ReviseOperation\\": "src/" 25 | } 26 | }, 27 | "extra": { 28 | "laravel": { 29 | "providers": [ 30 | "Backpack\\ReviseOperation\\ReviseOperationServiceProvider" 31 | ] 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are welcome and will be fully credited. 4 | 5 | Contributions are accepted via Pull Requests on [Github](https://github.com/backpack/reviseoperation). 6 | 7 | # Things you could do 8 | If you want to contribute but do not know where to start, this list provides some starting points. 9 | - Add license text 10 | - Remove rewriteRules.php 11 | - Set up TravisCI, StyleCI, ScrutinizerCI 12 | - Write a comprehensive ReadMe 13 | 14 | ## Pull Requests 15 | 16 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 17 | 18 | - **Document any change in behaviour** - Make sure the `readme.md` and any other relevant documentation are kept up-to-date. 19 | 20 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 21 | 22 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 23 | 24 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 25 | 26 | 27 | **Happy coding**! 28 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | # The license 2 | 3 | Copyright 2020 (c) Cristian Tabacitu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # ReviseOperation for Backpack for Laravel 2 | 3 | [![Latest Version on Packagist][ico-version]][link-packagist] 4 | [![Software License][ico-license]](LICENSE.md) 5 | [![Build Status][ico-travis]][link-travis] 6 | [![Total Downloads][ico-downloads]][link-downloads] 7 | [![StyleCI][ico-styleci]][link-styleci] 8 | 9 | Adds an interface for [```venturecraft/revisionable```](https://github.com/VentureCraft/revisionable) to your Backpack CRUDs, so that the admin can: 10 | - see the changes that have been made to an entry; 11 | - undo changes; 12 | 13 | [```venturecraft/revisionable```](https://github.com/VentureCraft/revisionable) allows you to store, see and undo changes to entries on an Eloquent model. This package just provides an admin interface for it, in the form of a Backpack operation, that you can use on the CrudControllers of entities that have the Revisionable trait. 14 | 15 | When used, this operation will show another button for each entry in the table view. On click, that button opens another page, which will allow an admin to see all changes and who made them: 16 | 17 | ![https://backpackforlaravel.com/uploads/docs-4-0/operations/revisions.png](https://backpackforlaravel.com/uploads/docs-4-0/operations/revisions.png) 18 | 19 | 20 | ## Installation 21 | 22 | **Step 1.** Require the package: 23 | 24 | ``` bash 25 | composer require backpack/revise-operation 26 | ``` 27 | 28 | This will automatically install ```venturecraft/revisionable``` too, if it's not already installed. 29 | 30 | **Step 2.** Create the Revisions table: 31 | 32 | ``` bash 33 | cp vendor/venturecraft/revisionable/src/migrations/2013_04_09_062329_create_revisions_table.php database/migrations/ && php artisan migrate 34 | ``` 35 | 36 | **Step 3.** Use RevisionableTrait on your model, and an ```identifiableName()``` method that returns an attribute on the model that the admin can use to distiguish between entries (ex: name, title, etc). If you are using another bootable trait be sure to override the boot method in your model. 37 | 38 | ```php 39 | namespace MyApp\Models; 40 | 41 | class Article extends Eloquent { 42 | use \Backpack\CRUD\CrudTrait, \Venturecraft\Revisionable\RevisionableTrait; 43 | 44 | public function identifiableName() 45 | { 46 | return $this->name; 47 | } 48 | 49 | // If you are using another bootable trait 50 | // be sure to override the boot method in your model 51 | public static function boot() 52 | { 53 | parent::boot(); 54 | } 55 | } 56 | ``` 57 | 58 | **Step 4.** In your CrudController, use the operation trait: 59 | ```php 60 | 'التعديلات', 18 | 'no_revisions' => 'لا يوجد تعديلات', 19 | 'revisions_for' => 'التعديلات ل', 20 | 'created_this' => 'قام بإنشاء', 21 | 'changed_the' => 'قام بتعديل', 22 | 'restore_this_value' => 'قام باسترداد هذه القيمة', 23 | 'from' => 'من', 24 | 'to' => 'إلى', 25 | 'undo' => 'تراجع', 26 | 'revision_restored' => 'تم استرداد القيمة بنجاح', 27 | 'guest_user' => 'مستخدم ضيف', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/bg/revise.php: -------------------------------------------------------------------------------- 1 | 'Версии', 18 | 'no_revisions' => 'Не бяха открити версии', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'създаде това', 21 | 'changed_the' => 'смени', 22 | 'restore_this_value' => 'Възстанови от ?', 23 | 'from' => 'от', 24 | 'to' => 'до', 25 | 'undo' => 'отмени', 26 | 'revision_restored' => 'Версията беше върната успешно.', 27 | 'guest_user' => 'Guest User', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/cs/revise.php: -------------------------------------------------------------------------------- 1 | 'Změny', 18 | 'no_revisions' => 'Žádné změny nebyly nalezeny', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'vytvořil', 21 | 'changed_the' => 'upravil', 22 | 'restore_this_value' => 'Obnovit tuto hodnotu', 23 | 'from' => 'z', 24 | 'to' => 'na', 25 | 'undo' => 'Vrátit', 26 | 'revision_restored' => 'Změny úspěšně obnoveny', 27 | 'guest_user' => 'Host uživatel', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/da-DK/revise.php: -------------------------------------------------------------------------------- 1 | 'Revisioner', 18 | 'no_revisions' => 'ingen revisioner fundet', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'lavede denne', 21 | 'changed_the' => 'ændrede denne', 22 | 'restore_this_value' => 'gendan denne værdi', 23 | 'from' => 'før', 24 | 'to' => 'efter', 25 | 'undo' => 'fortryd', 26 | 'revision_restored' => 'Revision gendannet', 27 | 'guest_user' => 'gæste bruger', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/da_DK/revise.php: -------------------------------------------------------------------------------- 1 | 'Revisioner', 18 | 'no_revisions' => 'ingen revisioner fundet', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'lavede denne', 21 | 'changed_the' => 'ændrede denne', 22 | 'restore_this_value' => 'gendan denne værdi', 23 | 'from' => 'før', 24 | 'to' => 'efter', 25 | 'undo' => 'fortryd', 26 | 'revision_restored' => 'Revision gendannet', 27 | 'guest_user' => 'gæste bruger', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/de/revise.php: -------------------------------------------------------------------------------- 1 | 'Revisionen', 18 | 'no_revisions' => 'Keine Revisionen gefunden', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'hat das erstellt', 21 | 'changed_the' => 'hat das geändert: ', 22 | 'restore_this_value' => 'Wiederherstellen', 23 | 'from' => 'von', 24 | 'to' => 'nach', 25 | 'undo' => 'Rückgängig', 26 | 'revision_restored' => 'Revision erfolgreich wiederhergestellt', 27 | 'guest_user' => 'Gast', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/el/revise.php: -------------------------------------------------------------------------------- 1 | 'Αναθεωρήσεις', 18 | 'no_revisions' => 'Δεν βρέθηκαν αναθεωρήσεις', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'δημιούργησε', 21 | 'changed_the' => 'άλλαξε', 22 | 'restore_this_value' => 'επανέφερε αυτή την τιμή', 23 | 'from' => 'από', 24 | 'to' => 'σε', 25 | 'undo' => 'Αναίρεση', 26 | 'revision_restored' => 'Η αναθεώρηση ανακτήθηκε με επιτυχία', 27 | 'guest_user' => 'Guest User', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/en/revise.php: -------------------------------------------------------------------------------- 1 | 'Revisions', 18 | 'no_revisions' => 'No revisions found', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'created this', 21 | 'changed_the' => 'changed the', 22 | 'restore_this_value' => 'Restore this value', 23 | 'from' => 'from', 24 | 'to' => 'to', 25 | 'undo' => 'Undo', 26 | 'revision_restored' => 'Revision successfully restored', 27 | 'guest_user' => 'Guest User', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/es/revise.php: -------------------------------------------------------------------------------- 1 | 'Las revisiones', 18 | 'no_revisions' => 'No hay revisiones encontradas', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'creado este', 21 | 'changed_the' => 'cambiado el', 22 | 'restore_this_value' => 'Restaurar este valor', 23 | 'from' => 'de', 24 | 'to' => 'a', 25 | 'undo' => 'Deshacer', 26 | 'revision_restored' => 'Revisión restaurada correctamente', 27 | 'guest_user' => 'Usuario invitado', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/fa/revise.php: -------------------------------------------------------------------------------- 1 | 'نسخه‌ها', 18 | 'no_revisions' => 'هیچ نسخه‌ای یافت نشد', 19 | 'created_this' => 'این را ایجاد کرده', 20 | 'changed_the' => 'تغییر', 21 | 'restore_this_value' => 'این مقدار را بازیابی کنید', 22 | 'from' => 'از', 23 | 'to' => 'به', 24 | 'undo' => 'خنثی کردن', 25 | 'revision_restored' => 'نسخه با موفقیت بازیابی شد.', 26 | 'guest_user' => 'کاربر مهمان', 27 | ]; 28 | -------------------------------------------------------------------------------- /resources/lang/fr-CA/revise.php: -------------------------------------------------------------------------------- 1 | 'Historique', 18 | 'no_revisions' => 'Pas d’historique', 19 | 'revisions_for' => 'Historique pour', 20 | 'created_this' => 'a créé', 21 | 'changed_the' => 'a modifié', 22 | 'restore_this_value' => 'Restaurer cette valeur', 23 | 'from' => 'De', 24 | 'to' => 'À', 25 | 'undo' => 'Annuler', 26 | 'revision_restored' => 'Valeur restaurée', 27 | 'guest_user' => 'Utilisateur invité', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/fr/revise.php: -------------------------------------------------------------------------------- 1 | 'Historique', 18 | 'no_revisions' => 'Pas d’historique', 19 | 'revisions_for' => 'Historique pour', 20 | 'created_this' => 'a créé', 21 | 'changed_the' => 'a modifié', 22 | 'restore_this_value' => 'Restaurer cette valeur', 23 | 'from' => 'De', 24 | 'to' => 'À', 25 | 'undo' => 'Annuler', 26 | 'revision_restored' => 'Valeur restaurée', 27 | 'guest_user' => 'Utilisateur invité', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/fr_CA/revise.php: -------------------------------------------------------------------------------- 1 | 'Historique', 18 | 'no_revisions' => 'Pas d’historique', 19 | 'revisions_for' => 'Historique pour', 20 | 'created_this' => 'a créé', 21 | 'changed_the' => 'a modifié', 22 | 'restore_this_value' => 'Restaurer cette valeur', 23 | 'from' => 'De', 24 | 'to' => 'À', 25 | 'undo' => 'Annuler', 26 | 'revision_restored' => 'Valeur restaurée', 27 | 'guest_user' => 'Utilisateur invité', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/id/revise.php: -------------------------------------------------------------------------------- 1 | 'Revisi', 18 | 'no_revisions' => 'Tidak ada revisi yang ditemukan', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'telah dibuat', 21 | 'changed_the' => 'mengubah', 22 | 'restore_this_value' => 'Kembalikan nilai ini', 23 | 'from' => 'dari', 24 | 'to' => 'ke', 25 | 'undo' => 'Batalkan', 26 | 'revision_restored' => 'Revisi berhasil dipulihkan', 27 | 'guest_user' => 'Pengguna Tamu', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/it/revise.php: -------------------------------------------------------------------------------- 1 | 'Revisioni', 18 | 'no_revisions' => 'Nessuna revisione trovata', 19 | 'revisions_for' => 'Revisioni per', 20 | 'created_this' => 'ha creato questo', 21 | 'changed_the' => 'ha cambiato il', 22 | 'restore_this_value' => 'ripristinare questo valore', 23 | 'from' => 'da', 24 | 'to' => 'a', 25 | 'undo' => 'Annulla', 26 | 'revision_restored' => 'Revisione ripristinata con successo', 27 | 'guest_user' => 'Un Ospite', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/ja/revise.php: -------------------------------------------------------------------------------- 1 | 'リビジョン', 18 | 'no_revisions' => 'リビジョンは見つかりません', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'が作成した', 21 | 'changed_the' => 'が変更した', 22 | 'restore_this_value' => 'この値を復元', 23 | 'from' => '旧', 24 | 'to' => '新', 25 | 'undo' => '復元', 26 | 'revision_restored' => 'リビジョンを復元しました', 27 | 'guest_user' => 'ゲストユーザー', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/lv/revise.php: -------------------------------------------------------------------------------- 1 | 'Revīzijas', 18 | 'no_revisions' => 'Revīzijas nav atrastas', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'izveidoja', 21 | 'changed_the' => 'izmainīja', 22 | 'restore_this_value' => 'Atjaunot vērtību', 23 | 'from' => 'no', 24 | 'to' => 'līdz', 25 | 'undo' => 'Atgriezt atpakaļ', 26 | 'revision_restored' => 'Revīzija veiksmīgi atjaunota', 27 | 'guest_user' => 'Lietotājs: viesis', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/nl/revise.php: -------------------------------------------------------------------------------- 1 | 'Revisies', 18 | 'no_revisions' => 'Geen revisies gevonden', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'heeft dit aangemaakt', 21 | 'changed_the' => 'heeft aangepast', 22 | 'restore_this_value' => 'Herstel deze waarde', 23 | 'from' => 'van', 24 | 'to' => 'naar', 25 | 'undo' => 'Ongedaan maken', 26 | 'revision_restored' => 'Revisie succesvol hersteld', 27 | ]; 28 | -------------------------------------------------------------------------------- /resources/lang/pt-BR/revise.php: -------------------------------------------------------------------------------- 1 | 'Revisões', 18 | 'no_revisions' => 'Não foram encontradas revisões', 19 | 'revisions_for' => 'Revisões para', 20 | 'created_this' => 'criou este', 21 | 'changed_the' => 'alterou este', 22 | 'restore_this_value' => 'Restaurou este valor', 23 | 'from' => 'de', 24 | 'to' => 'para', 25 | 'undo' => 'Desfazer', 26 | 'revision_restored' => 'Revisão restaurada com sucesso', 27 | 'guest_user' => 'Convidado', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/pt/revise.php: -------------------------------------------------------------------------------- 1 | 'Revisões', 18 | 'no_revisions' => 'Não foram encontradas revisões', 19 | 'revisions_for' => 'Revisões para', 20 | 'created_this' => 'criou este', 21 | 'changed_the' => 'alterou este', 22 | 'restore_this_value' => 'Restaurou este valor', 23 | 'from' => 'de', 24 | 'to' => 'para', 25 | 'undo' => 'Desfazer', 26 | 'revision_restored' => 'Revisão restaurada com sucesso', 27 | 'guest_user' => 'Convidado', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/pt_BR/revise.php: -------------------------------------------------------------------------------- 1 | 'Revisões', 18 | 'no_revisions' => 'Não foram encontradas revisões', 19 | 'revisions_for' => 'Revisões para', 20 | 'created_this' => 'criou este', 21 | 'changed_the' => 'alterou este', 22 | 'restore_this_value' => 'Restaurou este valor', 23 | 'from' => 'de', 24 | 'to' => 'para', 25 | 'undo' => 'Desfazer', 26 | 'revision_restored' => 'Revisão restaurada com sucesso', 27 | 'guest_user' => 'Convidado', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/ro/revise.php: -------------------------------------------------------------------------------- 1 | 'Revizii', 18 | 'no_revisions' => 'Nici o revizie', 19 | 'revisions_for' => 'Revizii pentru', 20 | 'created_this' => 'a generat înregistrarea', 21 | 'changed_the' => 'a schimbat câmpul', 22 | 'restore_this_value' => 'restabilește valoare', 23 | 'from' => 'valoare veche', 24 | 'to' => 'valoare nouă', 25 | 'undo' => 'Restabilește valoare anterioară', 26 | 'revision_restored' => 'Revizie restaurată cu succes', 27 | 'guest_user' => 'Vizitator', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/ru/revise.php: -------------------------------------------------------------------------------- 1 | 'Версии', 18 | 'no_revisions' => 'Версий не найдено', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'создал(а) это', 21 | 'changed_the' => 'изменил(а)', 22 | 'restore_this_value' => 'Восстановить это значение', 23 | 'from' => 'с', 24 | 'to' => 'по', 25 | 'undo' => 'Шаг назад', 26 | 'revision_restored' => 'Версия успешно восстановлена', 27 | 'guest_user' => 'Гость', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/sr/revise.php: -------------------------------------------------------------------------------- 1 | 'Revizije', 18 | 'no_revisions' => 'Nema revizija', 19 | 'revisions_for' => 'Revizije za', 20 | 'created_this' => 'je kreirao', 21 | 'changed_the' => 'je izmenio', 22 | 'restore_this_value' => 'Vrati vrednost', 23 | 'from' => 'prethodna vrednost', 24 | 'to' => 'nova vrednost', 25 | 'undo' => 'Undo', 26 | 'revision_restored' => 'Revizija uspešno vraćena', 27 | 'guest_user' => 'Gost', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/tr/revise.php: -------------------------------------------------------------------------------- 1 | 'Düzeltmeler', 18 | 'no_revisions' => 'Düzeltme bulunamadı', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => 'bunu oluşturdu', 21 | 'changed_the' => 'değişti', 22 | 'restore_this_value' => 'Bu değeri geri yükle', 23 | 'from' => 'dan', 24 | 'to' => 'buraya', 25 | 'undo' => 'Geri al', 26 | 'revision_restored' => 'Revizyon başarıyla geri yüklendi', 27 | 'guest_user' => 'Misafir Kullanıcı', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/uk/revise.php: -------------------------------------------------------------------------------- 1 | 15 | | 16 | */ 17 | 18 | // Revisions 19 | 'revisions' => 'Версії', 20 | 'no_revisions' => 'Версій не знайдено', 21 | 'revisions_for' => 'Версії для', 22 | 'created_this' => 'створив це', 23 | 'changed_the' => 'змінив', 24 | 'restore_this_value' => 'Відновити це значення', 25 | 'from' => 'з', 26 | 'to' => 'по', 27 | 'undo' => 'Скасувати', 28 | 'revision_restored' => 'Версію успішно відновлено', 29 | 'guest_user' => 'Гість', 30 | ]; 31 | -------------------------------------------------------------------------------- /resources/lang/zh-Hant/revise.php: -------------------------------------------------------------------------------- 1 | '修訂版本', 18 | 'no_revisions' => '找不到修訂版本', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => '建立的', 21 | 'changed_the' => '更改了', 22 | 'restore_this_value' => '回復這個值', 23 | 'from' => '由', 24 | 'to' => '到', 25 | 'undo' => '回復', 26 | 'revision_restored' => '成功回復修訂版本', 27 | 'guest_user' => '遊客', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/zh-cn/revise.php: -------------------------------------------------------------------------------- 1 | '修顶版本', 18 | 'no_revisions' => '找不到修订版本', 19 | 'revisions_for' => 'Revisions for', 20 | 'created_this' => '建立的', 21 | 'changed_the' => '更改了', 22 | 'restore_this_value' => '还原这个值', 23 | 'from' => '由', 24 | 'to' => '到', 25 | 'undo' => '撤销', 26 | 'revision_restored' => '成功恢复修订版本', 27 | 'guest_user' => '访客', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/views/revise_button.blade.php: -------------------------------------------------------------------------------- 1 | @if ($crud->hasAccess('revise') && count($entry->revisionHistory)) 2 | {{ trans('revise-operation::revise.revisions') }} 3 | @endif 4 | -------------------------------------------------------------------------------- /resources/views/revision_timeline.blade.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | @foreach($revisions as $revisionDate => $dateRevisions) 4 |

5 | {{ Carbon\Carbon::parse($revisionDate)->isoFormat(config('backpack.ui.default_date_format')) }} 6 |

7 | 8 | @foreach($dateRevisions as $history) 9 |
10 | 11 | @if($history->key == 'created_at' && !$history->old_value) 12 |
13 | {{ date('h:ia', strtotime($history->created_at)) }} - 14 | {{ $history->userResponsible()?$history->userResponsible()->name:trans('revise-operation::revise.guest_user') }} {{ trans('revise-operation::revise.created_this') }} {{ $crud->entity_name }} 15 |
16 | @else 17 |
18 | {{ date('h:ia', strtotime($history->created_at)) }} - 19 | {{ $history->userResponsible()?$history->userResponsible()->name:trans('revise-operation::revise.guest_user') }} {{ trans('revise-operation::revise.changed_the') }} {{ $history->fieldName() }} 20 |
21 |
22 | {!! csrf_field() !!} 23 | 25 |
26 |
27 |
28 |
29 |
30 |
{{ mb_ucfirst(trans('revise-operation::revise.from')) }}:
31 |
{{ mb_ucfirst(trans('revise-operation::revise.to')) }}:
32 |
33 |
34 |
{{ $history->oldValue() }}
35 |
{{ $history->newValue() }}
36 |
37 |
38 | @endif 39 |
40 | @endforeach 41 | @endforeach 42 |
43 | 44 | @section('after_scripts') 45 | 85 | @endsection 86 | 87 | @section('after_styles') 88 | {{-- Animations for new revisions after ajax calls --}} 89 | 103 | @endsection 104 | -------------------------------------------------------------------------------- /resources/views/revisions.blade.php: -------------------------------------------------------------------------------- 1 | @extends(backpack_view('blank')) 2 | 3 | @php 4 | $defaultBreadcrumbs = [ 5 | trans('backpack::crud.admin') => url(config('backpack.base.route_prefix'), 'dashboard'), 6 | $crud->entity_name_plural => url($crud->route), 7 | trans('revise-operation::revise.revisions') => false, 8 | ]; 9 | 10 | // if breadcrumbs aren't defined in the CrudController, use the default breadcrumbs 11 | $breadcrumbs = $breadcrumbs ?? $defaultBreadcrumbs; 12 | 13 | $heading = $crud->getHeading() ?? $crud->entity_name_plural; 14 | $subheading = $crud->getSubheading() ?? method_exists($entry, 'identifiableName') ? trans('revise-operation::revise.revisions_for').' "'.$entry->identifiableName().'"' : trans('revise-operation::revise.revisions'); 15 | @endphp 16 | 17 | @section('header') 18 |
19 |

20 | {!! $heading !!} 21 |

22 |

23 | {!! $subheading !!}. 24 |

25 | @if ($crud->hasAccess('list')) 26 |

27 | {{ 28 | trans('backpack::crud.back_to_all') }} {{ $crud->entity_name_plural }} 29 |

30 | @endif 31 |
32 | @endsection 33 | 34 | @section('content') 35 |
36 |
37 | 38 | 39 | @if(!count($revisions)) 40 |
41 |
42 |

{{ trans('revise-operation::revise.no_revisions') }}

43 |
44 |
45 | @else 46 | @include('revise-operation::revision_timeline') 47 | @endif 48 |
49 |
50 | @endsection 51 | -------------------------------------------------------------------------------- /src/ReviseOperation.php: -------------------------------------------------------------------------------- 1 | $routeName.'.listRevisions', 21 | 'uses' => $controller.'@listRevisions', 22 | 'operation' => 'revise', 23 | ]); 24 | 25 | Route::post($segment.'/{id}/revise/{revisionId}/restore', [ 26 | 'as' => $routeName.'.restoreRevision', 27 | 'uses' => $controller.'@restoreRevision', 28 | 'operation' => 'revise', 29 | ]); 30 | } 31 | 32 | /** 33 | * Add the default settings, buttons, etc that this operation needs. 34 | */ 35 | protected function setupReviseDefaults() 36 | { 37 | // allow access to the operation 38 | $this->crud->allowAccess('revise'); 39 | 40 | $this->crud->operation('revise', function () { 41 | $this->crud->loadDefaultOperationSettingsFromConfig(); 42 | }); 43 | 44 | $this->crud->operation(['list', 'show'], function () { 45 | // add a button in the line stack 46 | $this->crud->query->with('revisionHistory'); 47 | $this->crud->addButton('line', 'revise', 'view', 'revise-operation::revise_button', 'end'); 48 | }); 49 | 50 | // add a new method on the CrudPanel object to allow this operation 51 | // to call getRevisionsForEntry from multiple operation methods 52 | $this->crud->macro('getRevisionsForEntry', function ($id) { 53 | $revisions = []; 54 | 55 | // Group revisions by change date 56 | foreach ($this->getEntry($id)->revisionHistory as $history) { 57 | // Get just the date from the revision created timestamp 58 | $revisionDate = date('Y-m-d', strtotime((string) $history->created_at)); 59 | 60 | // Be sure to instantiate the initial grouping array 61 | if (! array_key_exists($revisionDate, $revisions)) { 62 | $revisions[$revisionDate] = []; 63 | } 64 | 65 | // Push onto the top of the current group - so we get orderBy decending timestamp 66 | array_unshift($revisions[$revisionDate], $history); 67 | } 68 | 69 | // Sort the array by timestamp descending (so that the most recent are at the top) 70 | krsort($revisions); 71 | 72 | return $revisions; 73 | }); 74 | } 75 | 76 | /** 77 | * Display the revisions for specified resource. 78 | * 79 | * @param int $id 80 | * @return Response 81 | */ 82 | public function listRevisions($id) 83 | { 84 | $this->crud->hasAccessOrFail('revise'); 85 | 86 | // get entry ID from Request (makes sure its the last ID for nested resources) 87 | $id = $this->crud->getCurrentEntryId() ?? $id; 88 | 89 | // calculate the revisions for that id 90 | $revisions = $this->crud->getRevisionsForEntry($id); 91 | 92 | $this->data['entry'] = $this->crud->getEntry($id); 93 | $this->data['crud'] = $this->crud; 94 | $this->data['title'] = $this->crud->getTitle() ?? mb_ucfirst($this->crud->entity_name).' '.trans('revise-operation::revise.revisions'); 95 | $this->data['id'] = $id; 96 | $this->data['revisions'] = $revisions; 97 | 98 | return view($this->crud->get('revise.listView') ?? 'revise-operation::revisions', $this->data); 99 | } 100 | 101 | /** 102 | * Restore a specific revision for the specified resource. 103 | * 104 | * Used via AJAX in the revisions view 105 | * 106 | * @param int $id 107 | * @return JSON Response containing the new revision that was created from the update 108 | * @return HTTP 500 if the request did not contain the revision ID 109 | */ 110 | public function restoreRevision($id) 111 | { 112 | $this->crud->hasAccessOrFail('revise'); 113 | 114 | $revisionId = \Request::input('revision_id', false); 115 | if (! $revisionId) { 116 | abort(500, 'Can\'t restore revision without revision_id'); 117 | } else { 118 | $entry = $this->crud->getEntryWithoutFakes($id); 119 | $revision = \Venturecraft\Revisionable\Revisionable::newModel()->findOrFail($revisionId); 120 | 121 | // Update the revisioned field with the old value 122 | $entry->update([$revision->key => $revision->old_value]); 123 | 124 | $this->data['entry'] = $this->crud->getEntry($id); 125 | $this->data['crud'] = $this->crud; 126 | $this->data['revisions'] = $this->crud->getRevisionsForEntry($id); // Reload revisions as they have changed 127 | 128 | // Rebuild the revision timeline HTML and return it to the AJAX call 129 | return view($this->crud->get('revise.timelineView') ?? 'revise-operation::revision_timeline', $this->data); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /src/ReviseOperationServiceProvider.php: -------------------------------------------------------------------------------- 1 | loadTranslationsFrom(__DIR__.'/../resources/lang', 'revise-operation'); 17 | 18 | // load views 19 | // - from 'resources/views/vendor/backpack/revise-operation' if they're there 20 | // - otherwise fall back to package views 21 | if (is_dir(resource_path('views/vendor/backpack/revise-operation'))) { 22 | $this->loadViewsFrom(resource_path('views/vendor/backpack/revise-operation'), 'revise-operation'); 23 | } 24 | $this->loadViewsFrom(__DIR__.'/../resources/views', 'revise-operation'); 25 | 26 | // Publishing is only necessary when using the CLI. 27 | if ($this->app->runningInConsole()) { 28 | $this->bootForConsole(); 29 | } 30 | } 31 | 32 | /** 33 | * Console-specific booting. 34 | * 35 | * @return void 36 | */ 37 | protected function bootForConsole() 38 | { 39 | // Publishing the views. 40 | $this->publishes([ 41 | __DIR__.'/../resources/views' => base_path('resources/views/vendor/backpack'), 42 | ], 'revise-operation.views'); 43 | 44 | // Publishing the translation files. 45 | $this->publishes([ 46 | __DIR__.'/../resources/lang' => resource_path('lang/vendor/backpack'), 47 | ], 'revise-operation.lang'); 48 | } 49 | } 50 | --------------------------------------------------------------------------------