Closed huge10 closed 4 years ago
Thanks for the report, I'll unfortunately only be able to look into this later this week.
I currently do this dirty hack in ApprovesChanges trait (mind you, novice developer):
if ($modification->approversRemaining == 0) {
if($modification->modifiable_id === null) {
$polymorphicModel = new $modification->modifiable_type();
$polymorphicModel->applyModificationChanges($modification, true);
} else {
$modification->modifiable->applyModificationChanges($modification, true);
}
}
When a model with RequiredApproval is freshly created, a Modification is created correctly. When I approve it using:
$user->approve($modification);
and since it has 0 remaining approvers left it tries to apply the changes and I get:
Call to a member function applyModificationChanges() on null
which makes sense as here:
$modification->modifiable->applyModificationChanges($modification, true);
I guess there is no 'modifiable' (as the record does not exist yet / has no idea).
Am I missing something here? Love your work, works perfect for changes but I can't seem to get it to work for creations.