serhiikorniienko / laravel-reportify
Simple Laravel package for content reporting and moderation
Fund package maintenance!
SerhiiKorniienko
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1
- orchestra/testbench: ^9.9.0|^10.0.0
- pestphp/pest: ^3.7.4
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
This package is not auto-updated.
Last update: 2025-03-30 11:15:15 UTC
README
Simple, yet powerful package for content reporting and moderation in Laravel applications. Add a Reportable
trait to your models and you're ready to go.
Installation
You can install the package via composer:
composer require serhiikorniienko/laravel-reportify
You can simply run install command to publish config, migrations and migrate the database:
php artisan reportify:install
Alternatively, you can publish the migration and config file separately:
php artisan vendor:publish --tag="reportify-migrations"
php artisan migrate
And a config file:
php artisan vendor:publish --tag="reportify-config"
Configuration
Basic configuration is stored in config/reportify.php
file. You can change the default values there.
global_threshold
- the number of reports required to mark a content as inappropriate for everyone.
return [ 'global_threshold' => 3, ];
Usage
Add the Reportable
trait to get started
use SerhiiKorniienko\Reportify\Reportable; class MyModel extends Model { // this trait adds the ability to report the model use Reportable; }
Report your model using the report
method
$model->report() ->withReporter($user) ->withReason('This is inappropriate content') ->withStatus('pending') ->create();
Check if the model should be available to a user
$model->visibleFor($user);
Currently, reportable model would not be visible for a user who has reported it. Also, it would not be visible for all users if the number of reports exceeds the global threshold.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.