All events live under RoundlyConsulting\Requests\Events and carry public properties:
| Event | Payload | Fired when |
|---|---|---|
RequestCreated | Request $request | A request is created. |
RequestStatusChanged | Request $request | The status really changes — by a direct decision, reopen, cancel, expire, or the engine resolving the approval request. Fires before RequestRejected, RequestCancelled or RequestExpired. |
ApprovalRecorded | Request $request, Model $actor | An approval is recorded through the facade or ResolveRequest — even when the request stays New. |
ApprovalRevoked | Request $request, Model $actor | The reopen signal: reopen() withdrew the actor’s decision (while the round is still open) or moved the request back to New. A reopen that changed nothing fires nothing. |
RequestRejected | Request $request, Model $actor | A rejection resolves the request to Rejected — after the status is written, so listeners see Rejected; the actor is the latest rejecting approver. |
RequestCancelled | Request $request | cancel() is called, or the approvals engine resolves the round as cancelled. |
RequestExpired | Request $request | expire() is called (directly or by requests:expire), or the approvals engine lapses the round. |
Listening
use Illuminate\Support\Facades\Event;
use RoundlyConsulting\Requests\Enums\Status;
use RoundlyConsulting\Requests\Events\RequestRejected;
use RoundlyConsulting\Requests\Events\RequestStatusChanged;
Event::listen(function (RequestStatusChanged $event): void {
if ($event->request->status === Status::Approved) {
// notify the author, write an audit entry, kick off the payout…
}
});
Event::listen(function (RequestRejected $event): void {
$event->request; // the Request
$event->actor; // the approver who rejected it
});Status events fire only for a status that really changed, after it is written: RequestStatusChanged first, then RequestRejected, RequestExpired or RequestCancelled. ApprovalRevoked is the reopen signal; ApprovalRecorded fires for every recorded approval.
The events fire however the change arrived: a round the approvals engine lapses (its own expiry, Approvals::expire()) expires the request and fires RequestStatusChanged and RequestExpired too, and a round the engine cancels fires RequestStatusChanged and RequestCancelled.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.