Status lifecycle
Every report carries a Status enum and starts as Pending:
| Case | Value | Open or terminal |
|---|---|---|
Status::Pending | pending | Open — the starting status. |
Status::InReview | in_review | Open — a moderator is looking at it. |
Status::Resolved | resolved | Terminal — the report was upheld. |
Status::Rejected | rejected | Terminal — no violation found. |
Status::Closed | closed | Terminal — a resolved report, filed away. |
Transitions
Moves are guarded by a transition table:
| From | Allowed next |
|---|---|
Pending | InReview, Resolved, Rejected |
InReview | Resolved, Rejected, Pending |
Resolved | Closed, Pending |
Rejected | Pending |
Closed | Pending |
use RoundlyConsulting\Reports\Enums\Status;
use RoundlyConsulting\Reports\Facades\Reports;
$report->status; // Status::Pending for a new report
Reports::review($report); // → InReview — fires ReportStatusChanged
Reports::review($report); // no-op when already in that status
Reports::changeStatus($report, Status::Closed); // InReview → Closed is not declared: throws when strict
$report->changeStatusTo(Status::Pending); // model shorthand — same path through the managerEvery move runs ChangeReportStatusAction: it fires ReportStatusChanged on every real change and is a no-op when the report is already in the target status. With strict_transitions on, an undeclared move throws InvalidStatusTransitionException; switch it off to allow any move.
Status helpers
Status::transitions(); // the full transition table
Status::Pending->allowedTransitions(); // [InReview, Resolved, Rejected]
Status::Resolved->canTransitionTo(Status::Closed); // true
Status::Rejected->isTerminal(); // true — Resolved, Rejected, Closed
Status::InReview->isOpen(); // true — Pending, InReview
Status::open(); // [Status::Pending, Status::InReview]
Status::InReview->label(); // "In Review"Status adopts the enums Helpers trait as well, so Status::toOptions() and Status::validationRule() are ready for filters and admin forms.
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.