-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
We have a use case where we want to capture events when our models' fields and relations are being updated
This can be achieved with the events that are included in the eloquent model HasEvents trait, for example
static::updating(function ($item) {
if ($item->isApprovalRequired() && $item->requiresApprovalWhen($item->getDirty()) === true) {
return self::captureSave($item);
}
});
This captures when the model is being updated, and if it requires us to approve it, captureSave will log the dirty fields and return false, thus negating whatever was to be updated
We've attempted to implement the same using the pivot events
static::pivotAttaching(function ($item, $relationName, $pivotIds) {
if ($item->isApprovalRequired() && $item->requiresApprovalWhen($item->getDirty()) === true) {
return self::capturePivot($item, $relationName, $pivotIds, 'pivotAttaching');
}
});
However returning false in these events doesn't seem to negate the attaching or detaching. They are still performed.
Is it possible to fix this?
Metadata
Metadata
Assignees
Labels
No labels