-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AuditableTransitionException Error on Morphmap on transitionTo() #357
Comments
Hi @watercayman, Thanks for reporting. I totally forgot that morphMap was a thing. I'll fix this ASAP. |
Awesome! Thank you, and thank you for the package. |
Confirm successful revert using transitionTo() on morphMapped objects with V5.0.2. Outstanding! Thank you again. |
@watercayman hi, can you tell me how did you configure the conf file to use polymorphic.
I do have User (commented out) and Administrator EDIT: also audits is registering remember token updates, which I don't want to log. Thanks. |
@dhcmega, sorry I was using poly auditable models, not multiple user models, so I'm afraid I can't help you :(. I'm not sure this is the right place for this question - perhaps stackoverflow would be better suited. |
Actual Behaviour
Audits work perfectly, storing correct basic data for the change (no many-to-many though).
Failure to find the morph (auditable_type) class when using transitionTo() method. Fails for all classes I am using the trait with, displaying the following error:
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, ];
These work for all morph_type actions on all other methods throughout the app, as expected.
Expected Behaviour
transitionTo() should read the morphMap like standard Laravel polymorphic relations and thus not fail the test on line 467 of Auditable class
Steps to Reproduce
$article = Article::find(123);
$audit = $article->audits()->first();
$article->transitionTo($audit);
Possible Solutions
The functionality is flawless doing this by hand using the final part of the transitionTo() method within Auditable:
I'd like to use the new internal code as it has excellent error and checking functionality. I'm not sure where to fix this to align with Laravel morph classes.
The text was updated successfully, but these errors were encountered: