All packages
Reports for Laravel
The Reports facade
Reports — RoundlyConsulting\Reports\Facades\Reports — is the recommended way in. Every mutation and every reason read goes through it:
use RoundlyConsulting\Approvals\Enums\ApprovalRule;
use RoundlyConsulting\Reports\Enums\Reason;
use RoundlyConsulting\Reports\Enums\Status;
use RoundlyConsulting\Reports\Facades\Reports;
// File — two fluent starts, or a DTO
Reports::report($post)->by($user)->for(Reason::Spam)->because('Spammy.')->create();
Reports::from($user)->about($post)->for('copyright')->create();
Reports::create($createReportData);
// Move and settle
Reports::review($report); // → InReview
Reports::resolve($report, by: $admin, note: 'Removed.');
Reports::reject($report, by: $admin, note: 'Not a violation.');
Reports::close($report); // → Closed (from Resolved)
Reports::changeStatus($report, Status::Pending);
// Multi-moderator sign-off
Reports::moderate($report)->requiring([$alice, $bob])->rule(ApprovalRule::Quorum)->quorum(2)->open();
// Housekeeping and reasons
Reports::prune(90); // → int
Reports::reasons(); // ['spam' => 'Spam', …]| Reports::… | Returns | What it does |
|---|---|---|
report($subject) / from($reporter) | PendingReport | Fluent filing, about a subject or by a reporter. |
create(CreateReportData $data) | Report | One-call filing from a DTO. |
moderate($report) | PendingModeration | Multi-moderator sign-off. |
resolve($report, ?$by, ?$note) | Report | Settle as resolved — or, under moderation, record a named moderator’s decision. |
reject($report, ?$by, ?$note) | Report | Settle as rejected — or, under moderation, record a named moderator’s decision. |
changeStatus($report, Status $status) | Report | Any declared move; $report->changeStatusTo() delegates here. |
review($report) / close($report) | Report | → InReview / → Closed. |
prune(?int $days = null, bool $force = false) | int | Delete terminal reports older than $days; what reports:prune runs. |
reasons() / reasonLabel($slug) / defaultReason() / allowsReason($slug) | array / string / string / bool | Reason reads — slug => label, a label, the default, an allow check. |
fake() | ReportsFake | Swap in the recording fake — see Testing. |
Builders
- report($subject) and from($reporter) return a PendingReport — about(), by(), asGuest(), for() / reason(), because(), then create(). See Filing reports.
- moderate($report) returns a PendingModeration — requiring(), rule(), quorum(), then open(). See Multi-moderator moderation.
Model shorthands
$user->giveReportTo(), $user->report() and $report->changeStatusTo() go through the same manager, so behaviour, events and Reports::fake() are identical whichever form you use.
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.