Model fails silently when saving unless 'saved' method exists in custom model #1984
Unanswered
fernando2amigos
asked this question in
Q&A
Replies: 1 comment 1 reply
-
There is no full support for |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm upgrading to PHP 8.1 (from 7.4) and with that also bumping versions of Laravel to 8.77.1 and of Laravel-Permissions 5.4.2
When running the migrations it simply stops after creating (saving to DB) the very first Permission or Role.
After retrying, the just created Permission or Role goes fine then halts on the next one.
I've observed that the insert to DB has succeeded, but code stopped without throwing Query or general Exception, nor SQL error.
After debugging I've found that the issue is when the Laravel calls the model's
saved()
method:This is our custom Permission model:
As you can see, it extends Spatie's Permission model, which also extends Laravel's Model which also uses HasEvents trait which has the
saved()
method that in this case is overloaded by our custom one.So I'm wondering the cause of this behavior: is it our code or maybe a bug in between Laravel and the package.
Adding the
saved()
method to Permission allowed me to go further until I hit the same situation for Role model.Beta Was this translation helpful? Give feedback.
All reactions