Each action dispatches an event carrying the affected review, so you can notify authors, alert support on low ratings or refresh search indexes without modifying the package. All live in RoundlyConsulting\Reviews\Events:
| Event | Dispatched when | Payload |
|---|---|---|
ReviewCreated | A review is created (after its photos are attached and committed). | review |
ReviewApproved | A review becomes approved — by Reviews::approve(), on create, or by re-moderation after an edit. | review |
ReviewRejected | A review becomes rejected — by Reviews::reject(), or by the moderator on create or after an edit. | review, ?string reason |
ReviewUpdated | Reviews::update() saves an edit. | review |
ReviewDeleted | Reviews::delete() soft-deletes a review. | review |
ReviewResponded | An owner response is created. | parent, response |
ReviewVoted | A helpful vote is cast or flipped. | review, vote |
ReviewVoteRemoved | An existing helpful vote is withdrawn. | review, voter |
ReviewVerified | Reviews::verify() or unverify() changes the verified flag. | review, bool verified (the new state) |
use Illuminate\Support\Facades\Event;
use RoundlyConsulting\Reviews\Events\ReviewCreated;
use RoundlyConsulting\Reviews\Events\ReviewRejected;
Event::listen(function (ReviewCreated $event): void {
logger()->info('New review', ['id' => $event->review->id]);
});
Event::listen(function (ReviewRejected $event): void {
// $event->review, $event->reason (?string)
});Worth knowing
- Events come from the actions, which the facade, an injected manager, the builder, the traits and the Review model helpers all run. A raw Eloquent change — $review->delete() on the model, say — fires no package event.
- A review that lands approved or rejected on create (approved(), auto_approve or the moderator) or after an edit fires ReviewApproved or ReviewRejected too, after ReviewCreated or ReviewUpdated.
- The package listens to ReviewApproved itself to warm photo variants on the queue when photos are enabled — however the review became approved.
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.