ApprovesChanges
trait ApprovesChanges (View source)
Applied to the model that casts approvals/disapprovals on a Modification (e.g. your User model).
approve()/disapprove() are interoperable with both shapes a Modification can take: when it has no ModificationItems it is decided as a whole (legacy behavior); when it has items, every pending item is resolved atomically instead. Use approveItem()/disapproveItem() to decide a single item without touching the others.
All four return false when the vote wasn't taken or couldn't be applied: the approver isn't authorized, the change was already decided (or is an audit row), its model no longer exists, or a listener vetoed the save.
Methods
Whether this model may approve the change. Override it to add your rules.
Whether this model may reject the change. Override it to add your rules.
Vote to approve a modification, or every pending item if it has any.
Vote to reject a modification, or every pending item if it has any.
Vote to approve a single item, without touching the others.
Vote to reject a single item, without touching the others.
The approvals cast by this model.
The disapprovals cast by this model.
Details
protected bool
authorizedToApprove(Modification $modification)
Whether this model may approve the change. Override it to add your rules.
protected bool
authorizedToDisapprove(Modification $modification)
Whether this model may reject the change. Override it to add your rules.
bool
approve(Modification $modification, string|null $reason = null)
Vote to approve a modification, or every pending item if it has any.
The change is applied once enough approvals are in. The vote and its effect share a transaction.
bool
disapprove(Modification $modification, string|null $reason = null)
Vote to reject a modification, or every pending item if it has any.
The change is rejected once enough disapprovals are in, and that rejection is final.
bool
approveItem(ModificationItem $item, string|null $reason = null)
Vote to approve a single item, without touching the others.
bool
disapproveItem(ModificationItem $item, string|null $reason = null)
Vote to reject a single item, without touching the others.
MorphMany
approvals()
The approvals cast by this model.
MorphMany
disapprovals()
The disapprovals cast by this model.