All packages
Reports for Laravel
Aggregation & querying
HasReports adds counting and lookup helpers to every reportable model:
use RoundlyConsulting\Reports\Enums\Status;
$post->reportsCount(); // total
$post->reportsCount(Status::Pending); // a specific status
$post->hasBeenReported();
$post->isReportedBy($user);
$post->pendingReports; // open reports relationQuery scopes
Post::query()->withReportCounts()->get(); // eager reports_count
Post::query()->mostReported()->get(); // by total report count
Post::query()->mostReported(Status::Pending)->get(); // count only pending
Post::query()->reportedMoreThan(5)->get(); // more than 5 reports
Post::query()->reportedMoreThan(5, Status::Pending)->get(); // more than 5 pending- withReportCounts() — eager-loads reports_count.
- mostReported(?Status) — adds reports_count and orders by it, highest first; pass a status to count only that status.
- reportedMoreThan(int, ?Status) — subjects with strictly more reports than the number given, optionally within one status; reports_count is included.
reportedMoreThan() filters through whereHas rather than HAVING on the count alias, so it runs on PostgreSQL and MySQL as well as SQLite.
Querying reports directly
The Report model ships its own scopes — withStatus, withReason, pending, resolved, rejected and open — for moderation queues and dashboards:
use RoundlyConsulting\Reports\Enums\Status;
use RoundlyConsulting\Reports\Models\Report;
// A moderation queue: every open report, newest first.
Report::query()->open()->with(['reporter', 'reported'])->latest()->paginate(25);
Report::query()->withStatus(Status::InReview)->get();
Report::query()->withReason('harassment')->get();
Report::query()->pending()->count();
Report::query()->resolved()->get();
Report::query()->rejected()->get();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.