Watercayman
Watercayman

Reputation: 8178

Laravel Auditing AuditableTransitionException Error on Morphmap on transitionTo()

I am able to successfully record changes to classes, and return what has been changed (not including many-to-many). However, I am unable to revert back any change using the built-in new transitionTo() method.

I get the following error on all classes:

Expected Auditable type App\XYZ, got XYZ instead

I have all of my morphable classes (which are all I am using for tracking audits) attached correctly within AppServiceProvider in a morphmap like so:

\Illuminate\Database\Eloquent\Relations\Relation::morphMap([
        'Employee' => \App\Employee::class,
];

All classes work correctly with all other Laravel morphTo methods.

The auditable code looks like it is tripping the error in line 467 of the Auditable class:

if (!$this instanceof $audit->auditable_type) {}

It doesn't appear to be looking to the map for any of the morphed classes. Or, I could be totally missing something of course!

Any help on how to get this to work using the auditing method -- has anyone gotten this to work with standard morph classes? (It will of course revert the class manually by looping on the old fields and saving the object).

Using Laravel 5.5 and the latest version (5.0) of Laravel-Auditing.

Upvotes: 1

Views: 386

Answers (1)

Watercayman
Watercayman

Reputation: 8178

Sent a note to the developer - this was in fact a bug. Vendor code was needed to include morphMapped objects.

Developer at Laravel Auditing responded within an hour and had a fix a few hours later. I can confirm this is now functioning as expected. Outstanding support.

Upvotes: 0

Related Questions