VentureCraft / revisionable

Easily create a revision history for any laravel model
http://twitter.com/duellsy
MIT License
2.56k stars 348 forks source link

Allow to get responsible when user is soft deleted #398

Open sebastienheyd opened 3 years ago

sebastienheyd commented 3 years ago

I've made a package that modify the users to allow to soft delete them.

When a user is soft deleted, the method userResponsible will return null, but the user is still in the database and is responsible for the revision. This can cause errors like "cannot get property ...... on null".

I've made my own Revision class to fix this, but I think this must be included by default because the user is responsible and must be loaded, deleted or not.

The fix is very simple, I just added withTrashed when getting the user.

fakeheal commented 2 years ago

+1 for this, but maybe we should add a property to allow other users to opt-in/opt-out of this feature.

For the time being, if you'd like to use @sebastienheyd changes:

  1. Install cweagans/composer-patches:

    composer require cweagans/composer-patches
  2. Download this PR's changes as .patch and places it ./{PROJECT_ROOT}/patches/venturecraft-revisionable.patch

  3. Update composer.json with:

    ....
    "extra": {
    "laravel": {
        "dont-discover": []
    },
    "patches": {
        "venturecraft/revisionable": {
            "Get responsible when user is soft deleted": "./patches/venturecraft-revisionable.patch"
        }
    }
    },
    ...
  4. Run composer install