roundly-consulting / reports-for-laravel
Easily handle reports on Laravel entities
Package info
github.com/roundly-consulting/reports-for-laravel
pkg:composer/roundly-consulting/reports-for-laravel
Fund package maintenance!
Requires
- php: ^8.4
- illuminate/contracts: ^12.0|^13.0
- roundly-consulting/approvals-for-laravel: ^1.0
- roundly-consulting/enums-for-laravel: ^1.0
- roundly-consulting/package-toolkit-for-laravel: ^1.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- nunomaduro/collision: ^8.8|^9.0
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- roundly-consulting/testing-for-laravel: ^1.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Reports for Laravel
Content moderation and flagging for Laravel. Let users or anonymous guests report any model with a typed reason, move each report through a guarded status lifecycle, block duplicate reports, require several moderators to agree before a report settles, and react when a subject crosses a reporting threshold.
Installation
Requires PHP 8.4, Laravel 12 or 13.
composer require roundly-consulting/reports-for-laravel php artisan vendor:publish --tag="reports-migrations" php artisan vendor:publish --tag="approvals-migrations" php artisan migrate
The approvals migrations back moderation and are needed too. If your reporter, reportable or
resolver models have UUID/ULID keys, set REPORTS_KEY_TYPE before migrating.
Usage
Prepare your models:
use Illuminate\Database\Eloquent\Model; use RoundlyConsulting\Reports\Contracts\Reportable; use RoundlyConsulting\Reports\Contracts\Reporter; use RoundlyConsulting\Reports\Traits\GivesReports; use RoundlyConsulting\Reports\Traits\HasReports; class User extends Model implements Reporter { use GivesReports; } class Post extends Model implements Reportable { use HasReports; }
File a report, then settle it:
use RoundlyConsulting\Reports\Enums\Reason; use RoundlyConsulting\Reports\Facades\Reports; $report = Reports::report($post) ->by($user) ->for(Reason::Abuse) // a typed, validated reason ->because('This post violates the community guidelines.') ->create(); // a second report by $user throws DuplicateReportException Reports::review($report); // pending → in review Reports::resolve($report, by: $moderator, note: 'Removed the post.'); $post->reportsCount(); // 1 Post::query()->mostReported()->get(); // the most-reported posts first
Documentation
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/reports-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
Support our work
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
License
The MIT License (MIT). Please see License File for more information.