### Install Reports for Laravel via Composer and Publish Migrations Source: https://github.com/roundly-consulting/reports-for-laravel/blob/main/README.md Run these commands to install the package and publish the required migrations. The approvals migrations are also needed for moderation. Set REPORTS_KEY_TYPE before migrating if your models use UUID/ULID keys, and set REPORTS_PRIMARY_KEY_TYPE=uuid if moderators use UUID keys. ```bash composer require roundly-consulting/reports-for-laravel php artisan vendor:publish --tag="reports-migrations" php artisan vendor:publish --tag="approvals-migrations" php artisan migrate ``` -------------------------------- ### Prepare Models with Reportable and Reporter Contracts Source: https://github.com/roundly-consulting/reports-for-laravel/blob/main/README.md Implement the Reporter and Reportable contracts on your models and use the GivesReports and HasReports traits. This enables the models to file and receive reports. ```php 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 and Settle a Report with the Reports Facade Source: https://github.com/roundly-consulting/reports-for-laravel/blob/main/README.md Use the Reports facade to create a report with a typed reason and optional note. A second report by the same user throws DuplicateReportException. Then review and resolve the report, and query the report count or most-reported posts. ```php 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 ```